



def read_int():

    return int(input().strip())





def read_ints():

    return list(map(int, input().strip().split(' ')))





def solve():

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

    N = read_int()

    h = read_ints()

    dp = [0, abs(h[1]-h[0])]

    for i in range(2, N):

        dp.append(min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]))

    return dp[-1]





if __name__ == '__main__':

    print((solve()))





def read_int():

    return int(input().strip())





def read_ints():

    return list(map(int, input().strip().split(' ')))





def solve():

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

    N = read_int()

    h = read_ints()

    a, b = 0, abs(h[1]-h[0])

    for i in range(2, N):

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

    return b





if __name__ == '__main__':

    print((solve()))

def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(" ")))


def solve():
    # dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2])
    N = read_int()
    h = read_ints()
    dp = [0, abs(h[1] - h[0])]
    for i in range(2, N):
        dp.append(
            min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2])
        )
    return dp[-1]


if __name__ == "__main__":
    print((solve()))

def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(" ")))


def solve():
    # dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2])
    N = read_int()
    h = read_ints()
    a, b = 0, abs(h[1] - h[0])
    for i in range(2, N):
        b, a = min(abs(h[i] - h[i - 1]) + b, abs(h[i] - h[i - 2]) + a), b
    return b


if __name__ == "__main__":
    print((solve()))

-    dp = [0, abs(h[1] - h[0])] +    a, b = 0, abs(h[1] - h[0]) -        dp.append( -            min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]) -        ) -    return dp[-1] +        b, a = min(abs(h[i] - h[i - 1]) + b, abs(h[i] - h[i - 2]) + a), b +    return b