#!/usr/bin/env python

# -*- coding: utf-8 -*-

import numpy as np



def main():

    INF = 10 ** 8

    N = int(eval(input()))

    weights = np.array(list(map(int, input().split()))).astype(int)

    

    dp_table = np.empty(N).astype(int)

    dp_table.fill(INF)

    dp_table[0] = 0

    dp_table[1] = abs(weights[1] - weights[0])

    

    for i in range(2, N):

        dp_table[i] = min(dp_table[i-1] + abs(weights[i] - weights[i-1]), dp_table[i-2] + abs(weights[i] - weights[i-2]))



    print((dp_table[N-1]))

    return 0



if __name__ == "__main__":

    main()

#!/usr/bin/env python



def chmin(a, b):

    return b if a > b else a



def chmax(a, b):

    return b if a < b else a



def main(N, h):

    INF = 10 ** 9

    dp = [INF] * (10 ** 5 + 10)

    dp[0] = 0

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

    for i in range(2, N):

        dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))

        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

    return dp[N-1]



if __name__ == '__main__':

    N = int(eval(input()))

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

    print((main(N, h)))

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np


def main():
    INF = 10**8
    N = int(eval(input()))
    weights = np.array(list(map(int, input().split()))).astype(int)
    dp_table = np.empty(N).astype(int)
    dp_table.fill(INF)
    dp_table[0] = 0
    dp_table[1] = abs(weights[1] - weights[0])
    for i in range(2, N):
        dp_table[i] = min(
            dp_table[i - 1] + abs(weights[i] - weights[i - 1]),
            dp_table[i - 2] + abs(weights[i] - weights[i - 2]),
        )
    print((dp_table[N - 1]))
    return 0


if __name__ == "__main__":
    main()

#!/usr/bin/env python
def chmin(a, b):
    return b if a > b else a


def chmax(a, b):
    return b if a < b else a


def main(N, h):
    INF = 10**9
    dp = [INF] * (10**5 + 10)
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    return dp[N - 1]


if __name__ == "__main__":
    N = int(eval(input()))
    h = list(map(int, input().split()))
    print((main(N, h)))

-# -*- coding: utf-8 -*- -import numpy as np +def chmin(a, b): +    return b if a > b else a -def main(): -    INF = 10**8 -    N = int(eval(input())) -    weights = np.array(list(map(int, input().split()))).astype(int) -    dp_table = np.empty(N).astype(int) -    dp_table.fill(INF) -    dp_table[0] = 0 -    dp_table[1] = abs(weights[1] - weights[0]) +def chmax(a, b): +    return b if a < b else a + + +def main(N, h): +    INF = 10**9 +    dp = [INF] * (10**5 + 10) +    dp[0] = 0 +    dp[1] = abs(h[1] - h[0]) -        dp_table[i] = min( -            dp_table[i - 1] + abs(weights[i] - weights[i - 1]), -            dp_table[i - 2] + abs(weights[i] - weights[i - 2]), -        ) -    print((dp_table[N - 1])) -    return 0 +        dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) +        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) +    return dp[N - 1] -    main() +    N = int(eval(input())) +    h = list(map(int, input().split())) +    print((main(N, h)))