贴一个序列重排吧 。。 n = int(input()) nums = list(map(int,input().split())) nums = sorted(nums) first = [] second = [] for i in range(n//2):     first.append(nums[i]) for i in range(n//2,n):     second.append(nums[i]) if n % 2:     temp = second[1]  else:     temp = -first[-1] x1 = sum(first) x2 = sum(second) res = 2*(x2-x1) - second[0] - temp print(res)