import sys input = sys.stdin.readline N=int(input()) C=sorted(map(int,input().split())) #print(C) A=abs(sum(C[:N//2]))-abs(sum(C[N//2:])) C.reverse() B=abs(sum(C[:N//2]))-abs(sum(C[N//2:])) print(min(abs(A),abs(B)))