Separate the task into two parts.
First, process the array—that is, simulate or model all the openings or closings. (As you process the array, do you need to distinguish between opening and closing?) This part will modify the contents of the array.
When that is done, your program should look at the array to count the number open, the number closed, and the locker most frequently switched. This part will not modify the contents of the array.