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