N = int(eval(input()))

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

INF = 1000 * 1000 * 1000

dp = [INF] * N



def absoluteDiff(a, b):

	if a > b:

		return a - b

	else:

		return b - a



dp[0] = 0

dp[1] = absoluteDiff(h[0], h[1])

for i in range(0, N - 2):

	dp[i + 1] = min(dp[i + 1], dp[i] + absoluteDiff(h[i], h[i + 1]))

	dp[i + 2] = dp[i] + absoluteDiff(h[i], h[i + 2])

dp[N - 1] = min(dp[N - 1], dp[N - 2] + absoluteDiff(h[N - 2], h[N - 1]))

print((str(dp[N - 1])))

INF=int('fffFFFFffffFFFF',16)



n=int(eval(input()))

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

dp=[INF] * 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()))
INF = 1000 * 1000 * 1000
dp = [INF] * N


def absoluteDiff(a, b):
    if a > b:
        return a - b
    else:
        return b - a


dp[0] = 0
dp[1] = absoluteDiff(h[0], h[1])
for i in range(0, N - 2):
    dp[i + 1] = min(dp[i + 1], dp[i] + absoluteDiff(h[i], h[i + 1]))
    dp[i + 2] = dp[i] + absoluteDiff(h[i], h[i + 2])
dp[N - 1] = min(dp[N - 1], dp[N - 2] + absoluteDiff(h[N - 2], h[N - 1]))
print((str(dp[N - 1])))

INF = int("fffFFFFffffFFFF", 16)
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF] * 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())) +INF = int("fffFFFFffffFFFF", 16) +n = int(eval(input())) -INF = 1000 * 1000 * 1000 -dp = [INF] * N - - -def absoluteDiff(a, b): -    if a > b: -        return a - b -    else: -        return b - a - - +dp = [INF] * n -dp[1] = absoluteDiff(h[0], h[1]) -for i in range(0, N - 2): -    dp[i + 1] = min(dp[i + 1], dp[i] + absoluteDiff(h[i], h[i + 1])) -    dp[i + 2] = dp[i] + absoluteDiff(h[i], h[i + 2]) -dp[N - 1] = min(dp[N - 1], dp[N - 2] + absoluteDiff(h[N - 2], h[N - 1])) -print((str(dp[N - 1]))) +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]))