n=int(input()) a=list(map(int,input().split())) if a[0]<0: if a[-1]<0: print(abs(2*a[0])) else: print(2*(a[-1]-a[0])) else: print(2*(a[-1]))