n=int(eval(input()))

h=[10**6]+list(map(int,input().split()))

c=[0]*(n+1)

for i in range(2,n+1):

  a=c[i-1]+abs(h[i]-h[i-1])

  b=c[i-2]+abs(h[i]-h[i-2])

  c[i]=min(a,b)

print((c[n]))
# AtCoder Educational DP Contest

# A - Frog 1





def main():

    n, *h = list(map(int, open(0).read().split()))



    DP = [0 for _ in range(n)]

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

    for i in range(2, n):

        c1, h1 = DP[i - 1], h[i - 1]

        c2, h2 = DP[i - 2], h[i - 2]

        h_now = h[i]

        a = c1 + abs(h1 - h_now)

        b = c2 + abs(h2 - h_now)

        DP[i] = min(a, b)



    res = DP[-1]

    print(res)





if __name__ == '__main__':

    main()

n = int(eval(input()))
h = [10**6] + list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(2, n + 1):
    a = c[i - 1] + abs(h[i] - h[i - 1])
    b = c[i - 2] + abs(h[i] - h[i - 2])
    c[i] = min(a, b)
print((c[n]))

# AtCoder Educational DP Contest
# A - Frog 1
def main():
    n, *h = list(map(int, open(0).read().split()))
    DP = [0 for _ in range(n)]
    DP[1] = abs(h[1] - h[0])
    for i in range(2, n):
        c1, h1 = DP[i - 1], h[i - 1]
        c2, h2 = DP[i - 2], h[i - 2]
        h_now = h[i]
        a = c1 + abs(h1 - h_now)
        b = c2 + abs(h2 - h_now)
        DP[i] = min(a, b)
    res = DP[-1]
    print(res)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -h = [10**6] + list(map(int, input().split())) -c = [0] * (n + 1) -for i in range(2, n + 1): -    a = c[i - 1] + abs(h[i] - h[i - 1]) -    b = c[i - 2] + abs(h[i] - h[i - 2]) -    c[i] = min(a, b) -print((c[n])) +# AtCoder Educational DP Contest +# A - Frog 1 +def main(): +    n, *h = list(map(int, open(0).read().split())) +    DP = [0 for _ in range(n)] +    DP[1] = abs(h[1] - h[0]) +    for i in range(2, n): +        c1, h1 = DP[i - 1], h[i - 1] +        c2, h2 = DP[i - 2], h[i - 2] +        h_now = h[i] +        a = c1 + abs(h1 - h_now) +        b = c2 + abs(h2 - h_now) +        DP[i] = min(a, b) +    res = DP[-1] +    print(res) + + +if __name__ == "__main__": +    main()