I'm installing a ceiling light to a fixture that was previously unused. However I'm having trouble because there are 2 groups of white wires. Which white wire should I connect with the white wire of my ceiling light? One group is a set of 3 wires and one group is a set of 2 wires.

Edit: I should also say that when I tried connecting the group with 2 white wires, turning off the switch for some reason short circuited the whole thing. I thought I might have done the grounding wire (the red one) wrong because I assumed I didn't connect the grounding wire. If my issue is not the white wires, can you please advise what else might be the issue?