N=int(eval(input()))

*H,=list(map(int,input().split()))



D=[10**4*N]*N



D[0]=0

for i in range(N):

    if 1<=i:

        #print(i,H[i],H[i-1],abs(H[i]-H[i-1]))

        D[i]=min(D[i],abs(H[i]-H[i-1])+D[i-1])

    if 2<=i:

        #print(i,H[i],H[i-2],abs(H[i]-H[i-2]))

        D[i]=min(D[i],abs(H[i]-H[i-2])+D[i-2])

print((D[-1]))
N=int(eval(input()))

*H,=list(map(int,input().split()))

D=[-1]*N

D[0]=0

D[1]=abs(H[1]-H[0])

for i in range(2,N):

    D[i]=min(abs(H[i]-H[i-1])+D[i-1],abs(H[i]-H[i-2])+D[i-2])

print((D[-1]))
N = int(eval(input()))
(*H,) = list(map(int, input().split()))
D = [10**4 * N] * N
D[0] = 0
for i in range(N):
    if 1 <= i:
        # print(i,H[i],H[i-1],abs(H[i]-H[i-1]))
        D[i] = min(D[i], abs(H[i] - H[i - 1]) + D[i - 1])
    if 2 <= i:
        # print(i,H[i],H[i-2],abs(H[i]-H[i-2]))
        D[i] = min(D[i], abs(H[i] - H[i - 2]) + D[i - 2])
print((D[-1]))

N = int(eval(input()))
(*H,) = list(map(int, input().split()))
D = [-1] * N
D[0] = 0
D[1] = abs(H[1] - H[0])
for i in range(2, N):
    D[i] = min(abs(H[i] - H[i - 1]) + D[i - 1], abs(H[i] - H[i - 2]) + D[i - 2])
print((D[-1]))

-D = [10**4 * N] * N +D = [-1] * N -for i in range(N): -    if 1 <= i: -        # print(i,H[i],H[i-1],abs(H[i]-H[i-1])) -        D[i] = min(D[i], abs(H[i] - H[i - 1]) + D[i - 1]) -    if 2 <= i: -        # print(i,H[i],H[i-2],abs(H[i]-H[i-2])) -        D[i] = min(D[i], abs(H[i] - H[i - 2]) + D[i - 2]) +D[1] = abs(H[1] - H[0]) +for i in range(2, N): +    D[i] = min(abs(H[i] - H[i - 1]) + D[i - 1], abs(H[i] - H[i - 2]) + D[i - 2])