N = int(input()) C = list(map(int,input().split())) print(abs(2*C[0]) + abs(2*C[-1]))