if __name__ == '__main__':

    N = int(eval(input()))

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

    

    DP = [0]

    for i in range(1, N):

        if i == 1:

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

            continue

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

    

    print((DP[-1]))

def dp():

    N = int(eval(input()))

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



    DP = [0]

    for i in range(1, N):

        if i == 1:

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

            continue

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

    print((DP[-1]))



dp()

if __name__ == "__main__":
    N = int(eval(input()))
    h = list(map(int, input().split()))
    DP = [0]
    for i in range(1, N):
        if i == 1:
            DP += [abs(h[i] - h[i - 1])]
            continue
        DP += [min(DP[i - 1] + abs(h[i] - h[i - 1]), DP[i - 2] + abs(h[i] - h[i - 2]))]
    print((DP[-1]))

def dp():
    N = int(eval(input()))
    h = list(map(int, input().split()))
    DP = [0]
    for i in range(1, N):
        if i == 1:
            DP += [abs(h[i] - h[i - 1])]
            continue
        DP += [min(DP[i - 1] + abs(h[i] - h[i - 1]), DP[i - 2] + abs(h[i] - h[i - 2]))]
    print((DP[-1]))


dp()

-if __name__ == "__main__": +def dp(): + + +dp()