n=int(eval(input()))

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

dp=[10**9]*n

dp[0]=0

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

for i in range(2,n):

    step1=dp[i-1]+abs(H[i]-H[i-1])

    step2=dp[i-2]+abs(H[i]-H[i-2])

    dp[i]=min(step1,step2)

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

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



DP = [0]*N

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



for i in range(2, N):

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

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

    if DP[i-2]+two <= DP[i-1]+one:

        DP[i] = DP[i-2]+two

    else:

        DP[i] = DP[i-1]+one



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

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

-n = int(eval(input())) +N = int(eval(input())) -dp = [10**9] * n -dp[0] = 0 -dp[1] = abs(H[1] - H[0]) -for i in range(2, n): -    step1 = dp[i - 1] + abs(H[i] - H[i - 1]) -    step2 = dp[i - 2] + abs(H[i] - H[i - 2]) -    dp[i] = min(step1, step2) -print((dp[-1])) +DP = [0] * N +DP[1] = abs(H[1] - H[0]) +for i in range(2, N): +    two = abs(H[i] - H[i - 2]) +    one = abs(H[i] - H[i - 1]) +    if DP[i - 2] + two <= DP[i - 1] + one: +        DP[i] = DP[i - 2] + two +    else: +        DP[i] = DP[i - 1] + one +print((DP[-1]))