N = int(eval(input()))

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

def dp_solver(x):#x番の足場に行くための最小コスト

    H = H_

    dp = [0]*len(H)

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

    for i in range(len(H)-2):

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

    return dp[x]

    

print((dp_solver(N-1)))
N = int(eval(input()))

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

def dp_solver(x):

    H = H_

    dp=[float('inf')]*N

    dp[0]=0

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

    for i in range(N-2):

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

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

    return dp[x-1]

print((dp_solver(N)))
N = int(eval(input()))
H_ = list(map(int, input().split()))


def dp_solver(x):  # x番の足場に行くための最小コスト
    H = H_
    dp = [0] * len(H)
    dp[1] = abs(H[0] - H[1])
    for i in range(len(H) - 2):
        dp[i + 2] = min(
            dp[i] + abs(H[i + 2] - H[i]), dp[i + 1] + abs(H[i + 2] - H[i + 1])
        )
    return dp[x]


print((dp_solver(N - 1)))

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


def dp_solver(x):
    H = H_
    dp = [float("inf")] * N
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(N - 2):
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))
        dp[i + 2] = min(dp[i + 2], dp[i + 1] + abs(H[i + 2] - H[i + 1]))
    return dp[x - 1]


print((dp_solver(N)))

-def dp_solver(x):  # x番の足場に行くための最小コスト +def dp_solver(x): -    dp = [0] * len(H) -    dp[1] = abs(H[0] - H[1]) -    for i in range(len(H) - 2): -        dp[i + 2] = min( -            dp[i] + abs(H[i + 2] - H[i]), dp[i + 1] + abs(H[i + 2] - H[i + 1]) -        ) -    return dp[x] +    dp = [float("inf")] * N +    dp[0] = 0 +    dp[1] = abs(H[1] - H[0]) +    for i in range(N - 2): +        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i])) +        dp[i + 2] = min(dp[i + 2], dp[i + 1] + abs(H[i + 2] - H[i + 1])) +    return dp[x - 1] -print((dp_solver(N - 1))) +print((dp_solver(N)))