n = int(eval(input()))

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



dp=[0] * n

for i in range(1, n):

  if i - 2 < 0:

    dp[i] = dp[i-1] + abs(h[i] - h[i-1])

  else:

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

  

print((dp[n-1]))
def main():

    n = int(eval(input()))

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



    cost_dp = [0] * n

    cost_dp[1] = abs(h[0] - h[1])

    for i in range(2,n):

        cost_dp[i] = min(cost_dp[i-2]+abs(h[i]- h[i-2]),cost_dp[i-1]+abs(h[i]-h[i-1]))

    print((cost_dp[n-1]))



if __name__ == '__main__':

    main()

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

def main():
    n = int(eval(input()))
    h = list(map(int, input().split()))
    cost_dp = [0] * n
    cost_dp[1] = abs(h[0] - h[1])
    for i in range(2, n):
        cost_dp[i] = min(
            cost_dp[i - 2] + abs(h[i] - h[i - 2]), cost_dp[i - 1] + abs(h[i] - h[i - 1])
        )
    print((cost_dp[n - 1]))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -h = list(map(int, input().split())) -dp = [0] * n -for i in range(1, n): -    if i - 2 < 0: -        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) -    else: -        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) -print((dp[n - 1])) +def main(): +    n = int(eval(input())) +    h = list(map(int, input().split())) +    cost_dp = [0] * n +    cost_dp[1] = abs(h[0] - h[1]) +    for i in range(2, n): +        cost_dp[i] = min( +            cost_dp[i - 2] + abs(h[i] - h[i - 2]), cost_dp[i - 1] + abs(h[i] - h[i - 1]) +        ) +    print((cost_dp[n - 1])) + + +if __name__ == "__main__": +    main()