n = int(input())
l = list(map(int, input().split()))
for i in range(len(l)):
  x =  l[i] - l[n- 1]
  x = x + l[i]
print(x)