# 検証のためのACの人のパクリですごめんなさい

N = int(eval(input()))

hs = [i for i in map(int, input().split())]



INF = 10*12

dp = [INF]*N



dp[0] = 0

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

for i in range(2, N):

  dp[i] = min(dp[i-1] +abs(hs[i]-hs[i-1]), dp[i-2] +abs(hs[i]-hs[i-2]))

print((dp[-1]))
def chmin(a, b):

  if a > b:

    return b

  return a



def main():

  N = int(eval(input()))

  hs = [i for i in map(int, input().split())]

  

  INF = 1e12

  dp = [INF]*N

  dp[0] = 0

  for i in range(1, N):

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

    if i > 1:

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

  print((dp[N-1]))

  return



if __name__ == '__main__':

  main()
# 検証のためのACの人のパクリですごめんなさい
N = int(eval(input()))
hs = [i for i in map(int, input().split())]
INF = 10 * 12
dp = [INF] * N
dp[0] = 0
dp[1] = abs(hs[0] - hs[1])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2]))
print((dp[-1]))

def chmin(a, b):
    if a > b:
        return b
    return a


def main():
    N = int(eval(input()))
    hs = [i for i in map(int, input().split())]
    INF = 1e12
    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        dp[i] = chmin(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1]))
        if i > 1:
            dp[i] = chmin(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]))
    print((dp[N - 1]))
    return


if __name__ == "__main__":
    main()

-# 検証のためのACの人のパクリですごめんなさい -N = int(eval(input())) -hs = [i for i in map(int, input().split())] -INF = 10 * 12 -dp = [INF] * N -dp[0] = 0 -dp[1] = abs(hs[0] - hs[1]) -for i in range(2, N): -    dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])) -print((dp[-1])) +def chmin(a, b): +    if a > b: +        return b +    return a + + +def main(): +    N = int(eval(input())) +    hs = [i for i in map(int, input().split())] +    INF = 1e12 +    dp = [INF] * N +    dp[0] = 0 +    for i in range(1, N): +        dp[i] = chmin(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1])) +        if i > 1: +            dp[i] = chmin(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2])) +    print((dp[N - 1])) +    return + + +if __name__ == "__main__": +    main()