P4995 跳跳! - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
n = int(input()) data = list(map(int,input().split())) data.append(0) data.sort() sum = 0 l = 0 r = len(data)-1 flag = 1 while l<=r: sum += (data[l]-data[r])**2 if flag: l += 1 flag = 0 else: r -= 1 flag = 1 print(sum)