# EduDPA - Frog 1

n = int(eval(input()))

lst = list(map(int, input().rstrip().split()))

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

for i in range(2, n):

    dif_1 = a + abs(lst[i] - lst[i - 2])

    dif_2 = b + abs(lst[i] - lst[i - 1])

    a, b = b, min(dif_1, dif_2)

print(b)
# EduDPA - Frog 1

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))

    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2)

    for i in range(2, n):

        dif1 = dp[i - 2] + abs(A[i] - A[i - 2])

        dif2 = dp[i - 1] + abs(A[i] - A[i - 1])

        dp[i] = min(dif1, dif2)

    print((dp[-1]))





if __name__ == "__main__":

    main()
# EduDPA - Frog 1
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
a, b = 0, abs(lst[0] - lst[1])
for i in range(2, n):
    dif_1 = a + abs(lst[i] - lst[i - 2])
    dif_2 = b + abs(lst[i] - lst[i - 1])
    a, b = b, min(dif_1, dif_2)
print(b)

# EduDPA - Frog 1
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2)
    for i in range(2, n):
        dif1 = dp[i - 2] + abs(A[i] - A[i - 2])
        dif2 = dp[i - 1] + abs(A[i] - A[i - 1])
        dp[i] = min(dif1, dif2)
    print((dp[-1]))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -lst = list(map(int, input().rstrip().split())) -a, b = 0, abs(lst[0] - lst[1]) -for i in range(2, n): -    dif_1 = a + abs(lst[i] - lst[i - 2]) -    dif_2 = b + abs(lst[i] - lst[i - 1]) -    a, b = b, min(dif_1, dif_2) -print(b) +def main(): +    n = int(eval(input())) +    A = tuple(map(int, input().rstrip().split())) +    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2) +    for i in range(2, n): +        dif1 = dp[i - 2] + abs(A[i] - A[i - 2]) +        dif2 = dp[i - 1] + abs(A[i] - A[i - 1]) +        dp[i] = min(dif1, dif2) +    print((dp[-1])) + + +if __name__ == "__main__": +    main()