N = int(eval(input()))                                                                                                                                             

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

dp = [float('inf')] * N                                                                                                                                      

dp[0] = 0                                                                                                                                                    

                                                                                                                                                             

def chmin(lst,a,b):                                                                                                                                          

    if lst[a]>b:                                                                                                                                             

        lst[a]=b                                                                                                                                             

                                                                                                                                                             

def chmax(lst,a,b):                                                                                                                                          

    if lst[a]<b:                                                                                                                                             

        lst[a]=b                                                                                                                                             

                                                                                                                                                             

for i in range(1,N):                                                                                                                                         

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

    if i>1:                                                                                                                                                  

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

                                                                                                                                                             

print((dp[N-1]))                                                                                                                                               

                      
#!/usr/bin/env python3

import sys





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

    dp = [float('inf')] * N

    dp[0] = 0

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



    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]))

    return





# Generated by 1.1.5 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()

N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0


def chmin(lst, a, b):
    if lst[a] > b:
        lst[a] = b


def chmax(lst, a, b):
    if lst[a] < b:
        lst[a] = b


for i in range(1, N):
    chmin(dp, i, dp[i - 1] + abs(h[i - 1] - h[i]))
    if i > 1:
        chmin(dp, i, dp[i - 2] + abs(h[i - 2] - h[i]))
print((dp[N - 1]))

#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    dp = [float("inf")] * N
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])
    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]))
    return


# Generated by 1.1.5 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()

-N = int(eval(input())) -h = list(map(int, input().split())) -dp = [float("inf")] * N -dp[0] = 0 +#!/usr/bin/env python3 +import sys -def chmin(lst, a, b): -    if lst[a] > b: -        lst[a] = b +def solve(N: int, h: "List[int]"): +    dp = [float("inf")] * N +    dp[0] = 0 +    dp[1] = abs(h[0] - h[1]) +    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])) +    return -def chmax(lst, a, b): -    if lst[a] < b: -        lst[a] = b +# Generated by 1.1.5 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) -for i in range(1, N): -    chmin(dp, i, dp[i - 1] + abs(h[i - 1] - h[i])) -    if i > 1: -        chmin(dp, i, dp[i - 2] + abs(h[i - 2] - h[i])) -print((dp[N - 1])) +if __name__ == "__main__": +    main()