def helper(h, n):

    res = [0]*n

    res[0] = 0

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

    for i in range(2, n):

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

    return res[-1]



def main():

    n = int(eval(input()))

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

    print((helper(h, n)))



if __name__ == "__main__":

    main()
def helper(h, n):

    prev = 0

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

    for i in range(2, n):

        next = min(curr+abs(h[i]-h[i-1]), prev+abs(h[i]-h[i-2]))

        prev = curr

        curr = next

    return curr



def main():

    n = int(eval(input()))

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

    print((helper(h, n)))



if __name__ == "__main__":

    main()
def helper(h, n):
    res = [0] * n
    res[0] = 0
    res[1] = abs(h[1] - h[0])
    for i in range(2, n):
        res[i] = min(
            res[i - 1] + abs(h[i] - h[i - 1]), res[i - 2] + abs(h[i] - h[i - 2])
        )
    return res[-1]


def main():
    n = int(eval(input()))
    h = list(map(int, input().split(" ")))
    print((helper(h, n)))


if __name__ == "__main__":
    main()

def helper(h, n):
    prev = 0
    curr = abs(h[1] - h[0])
    for i in range(2, n):
        next = min(curr + abs(h[i] - h[i - 1]), prev + abs(h[i] - h[i - 2]))
        prev = curr
        curr = next
    return curr


def main():
    n = int(eval(input()))
    h = list(map(int, input().split(" ")))
    print((helper(h, n)))


if __name__ == "__main__":
    main()

-    res = [0] * n -    res[0] = 0 -    res[1] = abs(h[1] - h[0]) +    prev = 0 +    curr = abs(h[1] - h[0]) -        res[i] = min( -            res[i - 1] + abs(h[i] - h[i - 1]), res[i - 2] + abs(h[i] - h[i - 2]) -        ) -    return res[-1] +        next = min(curr + abs(h[i] - h[i - 1]), prev + abs(h[i] - h[i - 2])) +        prev = curr +        curr = next +    return curr