N = int(eval(input()))

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

dp = []



def mins(minval, val):

	if minval < val:

			return minval

	else:

			return val



for i in range(N):

	dp.append(1000000000000)



for i in range(len(a)):

	if i == 0:

		dp[0] = 0

	if i == 2:

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

	

	

	dp[i] = min(dp[i], dp[i-1] + abs(a[i-1] - a[i]))

	dp[i] = min(dp[i], dp[i-2] + abs(a[i-2] - a[i]))

#print(dp)

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

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



def minVal(minInt, val):

    if minInt < val:

        return minInt

    else:

        return val



dp = [100000000000000] * N

(dp[0], dp[1]) = [0, abs(a[1]-a[0])]



for i in range(2,N):

    dp[i] = minVal(dp[i], dp[i - 1] + abs(a[i - 1] - a[i]))

    dp[i] = minVal(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]))

else:

    print((dp[N - 1]))
N = int(eval(input()))
a = list(map(int, input().split()))
dp = []


def mins(minval, val):
    if minval < val:
        return minval
    else:
        return val


for i in range(N):
    dp.append(1000000000000)
for i in range(len(a)):
    if i == 0:
        dp[0] = 0
    if i == 2:
        dp[1] = abs(a[1] - a[0])
    dp[i] = min(dp[i], dp[i - 1] + abs(a[i - 1] - a[i]))
    dp[i] = min(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]))
# print(dp)
print((dp[N - 1]))

N = int(eval(input()))
a = list(map(int, input().split()))


def minVal(minInt, val):
    if minInt < val:
        return minInt
    else:
        return val


dp = [100000000000000] * N
(dp[0], dp[1]) = [0, abs(a[1] - a[0])]
for i in range(2, N):
    dp[i] = minVal(dp[i], dp[i - 1] + abs(a[i - 1] - a[i]))
    dp[i] = minVal(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]))
else:
    print((dp[N - 1]))

-dp = [] -def mins(minval, val): -    if minval < val: -        return minval +def minVal(minInt, val): +    if minInt < val: +        return minInt -for i in range(N): -    dp.append(1000000000000) -for i in range(len(a)): -    if i == 0: -        dp[0] = 0 -    if i == 2: -        dp[1] = abs(a[1] - a[0]) -    dp[i] = min(dp[i], dp[i - 1] + abs(a[i - 1] - a[i])) -    dp[i] = min(dp[i], dp[i - 2] + abs(a[i - 2] - a[i])) -# print(dp) -print((dp[N - 1])) +dp = [100000000000000] * N +(dp[0], dp[1]) = [0, abs(a[1] - a[0])] +for i in range(2, N): +    dp[i] = minVal(dp[i], dp[i - 1] + abs(a[i - 1] - a[i])) +    dp[i] = minVal(dp[i], dp[i - 2] + abs(a[i - 2] - a[i])) +else: +    print((dp[N - 1]))