levels, and there is an even number of players.
Split everyone into pairs so that every pair has the same combined level. The synergy of a pair is the product of its two players' levels.
Return the total synergy of all pairs in such a split. If the players cannot be paired up with equal sums, return -1.levels=[6, 2, 4, 4, 1, 7] → 35
The pairs (1, 7), (2, 6) and (4, 4) each add up to 8. Synergy: 7 + 12 + 16 = 35.
levels=[5, 9] → 45
Two players make one pair with synergy 5 · 9 = 45.
levels=[1, 2, 2, 4] → -1
The weakest player (1) must team up with the strongest (4) for a sum of 5, but then 2 + 2 = 4 ≠ 5.
levels=[6, 2, 4, 4, 1, 7]
35
Run checks the first 3 tests in your browser. Submit checks all 124 tests on the server, hidden ones included.