N=int(eval(input()))

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

DP=[0]*N

DP[0]=0

DP[1]=abs(h[1]-h[0])+DP[0]

i=2

while i<N:

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

  i+=1

print((DP[-1]))
def main():

  N=int(eval(input()))

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

  DP=[0]*N

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

  for i in range(2,N):

    # from 2step before

    pre_2=DP[i-2] + abs(h[i]-h[i-2])

    pre_1=DP[i-1] + abs(h[i]-h[i-1])

    DP[i]=min(pre_1,pre_2)

    pass

  print((DP[-1]))



if __name__ == '__main__':

  main()



N = int(eval(input()))
h = list(map(int, input().split()))
DP = [0] * N
DP[0] = 0
DP[1] = abs(h[1] - h[0]) + DP[0]
i = 2
while i < N:
    DP[i] = min(abs(h[i] - h[i - 1]) + DP[i - 1], abs(h[i] - h[i - 2]) + DP[i - 2])
    i += 1
print((DP[-1]))

def main():
    N = int(eval(input()))
    h = list(map(int, input().split()))
    DP = [0] * N
    DP[1] = abs(h[1] - h[0])
    for i in range(2, N):
        # from 2step before
        pre_2 = DP[i - 2] + abs(h[i] - h[i - 2])
        pre_1 = DP[i - 1] + abs(h[i] - h[i - 1])
        DP[i] = min(pre_1, pre_2)
        pass
    print((DP[-1]))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -h = list(map(int, input().split())) -DP = [0] * N -DP[0] = 0 -DP[1] = abs(h[1] - h[0]) + DP[0] -i = 2 -while i < N: -    DP[i] = min(abs(h[i] - h[i - 1]) + DP[i - 1], abs(h[i] - h[i - 2]) + DP[i - 2]) -    i += 1 -print((DP[-1])) +def main(): +    N = int(eval(input())) +    h = list(map(int, input().split())) +    DP = [0] * N +    DP[1] = abs(h[1] - h[0]) +    for i in range(2, N): +        # from 2step before +        pre_2 = DP[i - 2] + abs(h[i] - h[i - 2]) +        pre_1 = DP[i - 1] + abs(h[i] - h[i - 1]) +        DP[i] = min(pre_1, pre_2) +        pass +    print((DP[-1])) + + +if __name__ == "__main__": +    main()