"""

author : halo2halo

date : 4, Feb, 2020

"""



import sys



# import itertools

# import math



# import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, *H = list(map(int, read().split()))

dp = [0] * N

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



for i in range(2, N):

    dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])



ans = dp[-1]

print(ans)

"""

author : halo2halo

date : 4, Feb, 2020

"""



import sys



# import itertools

# import math



# import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, *H = list(map(int, read().split()))

dp = [0] * N



for i in range(1, N):

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

    if i > 1:

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

        if x > y: 

            x = y

    dp[i] = x



ans = dp[-1]

print(ans)

"""
author : halo2halo
date : 4, Feb, 2020
"""
import sys

# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])
ans = dp[-1]
print(ans)

"""
author : halo2halo
date : 4, Feb, 2020
"""
import sys

# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
for i in range(1, N):
    x = dp[i - 1] + abs(H[i] - H[i - 1])
    if i > 1:
        y = dp[i - 2] + abs(H[i] - H[i - 2])
        if x > y:
            x = y
    dp[i] = x
ans = dp[-1]
print(ans)

-dp[1] = abs(H[1] - H[0]) -for i in range(2, N): -    dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2]) +for i in range(1, N): +    x = dp[i - 1] + abs(H[i] - H[i - 1]) +    if i > 1: +        y = dp[i - 2] + abs(H[i] - H[i - 2]) +        if x > y: +            x = y +    dp[i] = x