import sys

import numpy as np

from numba import njit



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



def main(H):

    dp = np.zeros_like(H)

    dp[1] = abs(H[1] - H[0])

    for n in range(2, len(H)):

        x = dp[n - 1] + abs(H[n - 1] - H[n])

        y = dp[n - 2] + abs(H[n - 2] - H[n])

        dp[n] = min(x, y)

    return dp[-1]



signature = '(i8[:],)'

if sys.argv[-1] == 'ONLINE_JUDGE':

    from numba.pycc import CC

    cc = CC('my_module')

    cc.export('main', signature)(main)

    cc.compile()



from my_module import main



H = np.array(read().split(), np.int64)[1:]



print((main(H)))
import sys

import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



def main(H):

    dp = np.zeros_like(H)

    dp[1] = abs(H[1] - H[0])

    for n in range(2, len(H)):

        x = dp[n - 1] + abs(H[n - 1] - H[n])

        y = dp[n - 2] + abs(H[n - 2] - H[n])

        dp[n] = min(x, y)

    return dp[-1]



signature = '(i8[:],)'

if sys.argv[-1] == 'ONLINE_JUDGE':

    from numba.pycc import CC

    cc = CC('my_module')

    cc.export('main', signature)(main)

    cc.compile()



from my_module import main



H = np.array(read().split(), np.int64)[1:]



print((main(H)))
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main(H):
    dp = np.zeros_like(H)
    dp[1] = abs(H[1] - H[0])
    for n in range(2, len(H)):
        x = dp[n - 1] + abs(H[n - 1] - H[n])
        y = dp[n - 2] + abs(H[n - 2] - H[n])
        dp[n] = min(x, y)
    return dp[-1]


signature = "(i8[:],)"
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba.pycc import CC

    cc = CC("my_module")
    cc.export("main", signature)(main)
    cc.compile()
from my_module import main

H = np.array(read().split(), np.int64)[1:]
print((main(H)))

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main(H):
    dp = np.zeros_like(H)
    dp[1] = abs(H[1] - H[0])
    for n in range(2, len(H)):
        x = dp[n - 1] + abs(H[n - 1] - H[n])
        y = dp[n - 2] + abs(H[n - 2] - H[n])
        dp[n] = min(x, y)
    return dp[-1]


signature = "(i8[:],)"
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba.pycc import CC

    cc = CC("my_module")
    cc.export("main", signature)(main)
    cc.compile()
from my_module import main

H = np.array(read().split(), np.int64)[1:]
print((main(H)))

-from numba import njit