def LI(): return list(map(int, input().split()))



n = int(eval(input()))

h = LI()

h1 = [abs(h[i+1] - h[i]) for i in range(n-1)]

h2 = [abs(h[i+2] - h[i]) for i in range(n-2)]



dp = [0] * n

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

for i in range(n-2):

    dp[i+2] = min(

        dp[i+1] + h1[i+1],

        dp[i] + h2[i],

    )



print((dp[-1]))

#!/usr/bin/env python3

import sys





def solve(N: int, h: "List[int]"):

    dp = [0] * N

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

    for i in range(2, N):

        dp[i] = min(

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

            dp[i-2] + abs(h[i] - h[i-2])

        )

    print((dp[-1]))





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    solve(N, h)



if __name__ == '__main__':

    main()

def LI():
    return list(map(int, input().split()))


n = int(eval(input()))
h = LI()
h1 = [abs(h[i + 1] - h[i]) for i in range(n - 1)]
h2 = [abs(h[i + 2] - h[i]) for i in range(n - 2)]
dp = [0] * n
dp[0], dp[1] = 0, abs(h[1] - h[0])
for i in range(n - 2):
    dp[i + 2] = min(
        dp[i + 1] + h1[i + 1],
        dp[i] + h2[i],
    )
print((dp[-1]))

#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    dp = [0] * N
    dp[0], dp[1] = 0, abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
    print((dp[-1]))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)


if __name__ == "__main__":
    main()

-def LI(): -    return list(map(int, input().split())) +#!/usr/bin/env python3 +import sys -n = int(eval(input())) -h = LI() -h1 = [abs(h[i + 1] - h[i]) for i in range(n - 1)] -h2 = [abs(h[i + 2] - h[i]) for i in range(n - 2)] -dp = [0] * n -dp[0], dp[1] = 0, abs(h[1] - h[0]) -for i in range(n - 2): -    dp[i + 2] = min( -        dp[i + 1] + h1[i + 1], -        dp[i] + h2[i], -    ) -print((dp[-1])) +def solve(N: int, h: "List[int]"): +    dp = [0] * N +    dp[0], dp[1] = 0, abs(h[1] - h[0]) +    for i in range(2, N): +        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +    print((dp[-1])) + + +# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template) +def main(): +    def iterate_tokens(): +        for line in sys.stdin: +            for word in line.split(): +                yield word + +    tokens = iterate_tokens() +    N = int(next(tokens))  # type: int +    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]" +    solve(N, h) + + +if __name__ == "__main__": +    main()