N=int(eval(input()))

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

cost=0

t1,t2=0,0

A=[0]*(N)

i=1

while i<N:

  if i==1:

    A[i]=abs(H[i]-H[i-1])

    #print(i,A[i])

  elif i==2:

    t1=abs(H[i]-H[i-2])

    t2=abs(H[i]-H[i-1])+abs(H[i-2]-H[i-1])

    A[i]=min(t1,t2)

    #print(i,A[i],t1,t2)

  else:

    t1=abs(H[i]-H[i-1])+A[i-1]

    t2=abs(H[i]-H[i-2])+A[i-2]

    A[i]=min(t1,t2)

    #print(i,A[i],t1,t2)

  i=i+1

#print(A)

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

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

DP=[0]*N

DP[0]=0

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

for i in range(2,N):

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

print((DP[N-1]))
N = int(eval(input()))
H = list(map(int, input().split()))
cost = 0
t1, t2 = 0, 0
A = [0] * (N)
i = 1
while i < N:
    if i == 1:
        A[i] = abs(H[i] - H[i - 1])
        # print(i,A[i])
    elif i == 2:
        t1 = abs(H[i] - H[i - 2])
        t2 = abs(H[i] - H[i - 1]) + abs(H[i - 2] - H[i - 1])
        A[i] = min(t1, t2)
        # print(i,A[i],t1,t2)
    else:
        t1 = abs(H[i] - H[i - 1]) + A[i - 1]
        t2 = abs(H[i] - H[i - 2]) + A[i - 2]
        A[i] = min(t1, t2)
        # print(i,A[i],t1,t2)
    i = i + 1
# print(A)
print((A[N - 1]))

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

-cost = 0 -t1, t2 = 0, 0 -A = [0] * (N) -i = 1 -while i < N: -    if i == 1: -        A[i] = abs(H[i] - H[i - 1]) -        # print(i,A[i]) -    elif i == 2: -        t1 = abs(H[i] - H[i - 2]) -        t2 = abs(H[i] - H[i - 1]) + abs(H[i - 2] - H[i - 1]) -        A[i] = min(t1, t2) -        # print(i,A[i],t1,t2) -    else: -        t1 = abs(H[i] - H[i - 1]) + A[i - 1] -        t2 = abs(H[i] - H[i - 2]) + A[i - 2] -        A[i] = min(t1, t2) -        # print(i,A[i],t1,t2) -    i = i + 1 -# print(A) -print((A[N - 1])) +DP = [0] * N +DP[0] = 0 +DP[1] = abs(H[1] - H[0]) +for i in range(2, N): +    DP[i] = min((abs(H[i] - H[i - 1]) + DP[i - 1]), (abs(H[i] - H[i - 2]) + DP[i - 2])) +print((DP[N - 1]))