#############  B  #############
import numpy as np
N = int(input())
x = list(map(int, input().split()))
li = np.array(range(2**(N-2),low+dif*(N-1),2**(N-3)))
d = np.diff(x,n=1)
SUM = np.dot(li,d)
print(SUM)