n=int(input()) c=list(map(int,input().split())) c.sort() a=sum([abs(x) for x in c[:n//2]]) b=sum([abs(x) for x in c[n//2:]]) ans0=abs(a-b) c.reverse() a=sum([abs(x) for x in c[:n//2]]) b=sum([abs(x) for x in c[n//2:]]) ans1=abs(a-b) print(min(ans0,ans1))