def main():

    n, height = getInputs()



    cost = [0] * n

    cost[1] = abs(height[0] - height[1])



    for i in range(2, n):

        cost[i] = min(

            cost[i - 1] + abs(height[i] - height[i - 1]),

            cost[i - 2] + abs(height[i] - height[i - 2])

        )



    print((cost[-1]))



def getInputs():

    return int(eval(input())), tuple([int(x) for x in input().split()])



main()

n = int(eval(input()))



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



dp = [0] * n



dp[0] = 0

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





for i in range(2,n):

    custo1 = dp[i-1] + abs(pedras[i-1] - pedras[i])

    custo2 = dp[i-2] + abs(pedras[i-2] - pedras[i])

    dp[i] = min(custo1,custo2)



print((dp[n-1]))

def main():
    n, height = getInputs()
    cost = [0] * n
    cost[1] = abs(height[0] - height[1])
    for i in range(2, n):
        cost[i] = min(
            cost[i - 1] + abs(height[i] - height[i - 1]),
            cost[i - 2] + abs(height[i] - height[i - 2]),
        )
    print((cost[-1]))


def getInputs():
    return int(eval(input())), tuple([int(x) for x in input().split()])


main()

n = int(eval(input()))
pedras = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(pedras[0] - pedras[1])
for i in range(2, n):
    custo1 = dp[i - 1] + abs(pedras[i - 1] - pedras[i])
    custo2 = dp[i - 2] + abs(pedras[i - 2] - pedras[i])
    dp[i] = min(custo1, custo2)
print((dp[n - 1]))

-def main(): -    n, height = getInputs() -    cost = [0] * n -    cost[1] = abs(height[0] - height[1]) -    for i in range(2, n): -        cost[i] = min( -            cost[i - 1] + abs(height[i] - height[i - 1]), -            cost[i - 2] + abs(height[i] - height[i - 2]), -        ) -    print((cost[-1])) - - -def getInputs(): -    return int(eval(input())), tuple([int(x) for x in input().split()]) - - -main() +n = int(eval(input())) +pedras = list(map(int, input().split())) +dp = [0] * n +dp[0] = 0 +dp[1] = abs(pedras[0] - pedras[1]) +for i in range(2, n): +    custo1 = dp[i - 1] + abs(pedras[i - 1] - pedras[i]) +    custo2 = dp[i - 2] + abs(pedras[i - 2] - pedras[i]) +    dp[i] = min(custo1, custo2) +print((dp[n - 1]))