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