| Contests - ACM Student Chapter - PSUT |
|---|
| Private |
| Spectator |
| ZU JCPC Qualification 2026 |
|---|
| Finished |
zi is feeling incredibly sleepy during a late-night coding round. To stay awake, she has lined up $$$n$$$ cups of coffee on her desk. The $$$i$$$-th cup has a specific caffeine level represented by an integer $$$a_i$$$.
She knows her limits: to fully wake up and solve problems, she must drink exactly three cups of coffee that have the exact same caffeine level.
Given the caffeine levels of all $$$n$$$ cups, help zi find a caffeine level that appears at least three times so she can wake up. If no such caffeine level exists, print $$$-1$$$ so she knows it's time to give up and just go to sleep.
First line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains contains an integer $$$n$$$ ($$$1 \le n \le 2*10^5$$$) — the total number of coffee cups on the desk.
Second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — the caffeine levels of each coffee cup.
For each test case, print any caffeine level that appears at least three times. If there is no such value, print $$$-1$$$.
51132 2 272 2 3 3 4 2 251 2 3 4 561 3 3 1 1 3
-1 2 2 -1 1
| Name |
|---|

