Option 1 -> "has ended" uses present perfect tense, which is incorrect for describing past events that occurred before another past action.
Option 2 -> Uses past perfect tense ("had already ended, had gathered") to correctly show both actions were completed before the arrival.
Option 3 -> "ended" (simple past) and "gather" (present tense) fail to show the proper sequence of past events.
Option 4 -> "was ending" suggests the concert was still in progress upon arrival, which contradicts the context of the crowd already gathering.
Hence, Option 2: had already ended, had gathered -> The phrase "By the time we arrived" signals that both the concert ending and the crowd gathering happened before the arrival, requiring the past perfect tense to indicate actions completed prior to another past action -> correct