def max_team_power(strengths): N = len(strengths) strengths.sort() max_power = 0 i, j = 0, N - 1 while i < j: max_power += strengths[i] ^ strengths[j] i += 1 j -= 1 return max_power