INF = 1 << 64





def calc_cost(height1, height2):

    return abs(height1 - height2)





def main(n, heights):

    heights.append(INF)

    heights.append(INF)

    costs = [INF for i in range(n + 2)]

    costs[0] = 0

    for i in range(n):

        costs[i + 1] = min(costs[i + 1], calc_cost(heights[i], heights[i + 1]) + costs[i])

        costs[i + 2] = min(costs[i + 2], calc_cost(heights[i], heights[i + 2]) + costs[i])

    return costs[n - 1]





if __name__ == '__main__':

    N = int(eval(input()))

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

    print((main(N, H)))

N = int(eval(input()))



heights = tuple(map(int, input().split(' ')))



dp = [0] * (N + 1)



dp[1] = 0

dp[2] = abs(heights[0] - heights[1])



for hi, i in enumerate(list(range(3, N + 1)), start=2):

    dp[i] = min(

        dp[i - 1] + abs(heights[hi] - heights[hi - 1]),

        dp[i - 2] + abs(heights[hi] - heights[hi - 2]),

    )



print((dp[N]))

INF = 1 << 64


def calc_cost(height1, height2):
    return abs(height1 - height2)


def main(n, heights):
    heights.append(INF)
    heights.append(INF)
    costs = [INF for i in range(n + 2)]
    costs[0] = 0
    for i in range(n):
        costs[i + 1] = min(
            costs[i + 1], calc_cost(heights[i], heights[i + 1]) + costs[i]
        )
        costs[i + 2] = min(
            costs[i + 2], calc_cost(heights[i], heights[i + 2]) + costs[i]
        )
    return costs[n - 1]


if __name__ == "__main__":
    N = int(eval(input()))
    H = list(map(int, input().split()))
    print((main(N, H)))

N = int(eval(input()))
heights = tuple(map(int, input().split(" ")))
dp = [0] * (N + 1)
dp[1] = 0
dp[2] = abs(heights[0] - heights[1])
for hi, i in enumerate(list(range(3, N + 1)), start=2):
    dp[i] = min(
        dp[i - 1] + abs(heights[hi] - heights[hi - 1]),
        dp[i - 2] + abs(heights[hi] - heights[hi - 2]),
    )
print((dp[N]))

-INF = 1 << 64 - - -def calc_cost(height1, height2): -    return abs(height1 - height2) - - -def main(n, heights): -    heights.append(INF) -    heights.append(INF) -    costs = [INF for i in range(n + 2)] -    costs[0] = 0 -    for i in range(n): -        costs[i + 1] = min( -            costs[i + 1], calc_cost(heights[i], heights[i + 1]) + costs[i] -        ) -        costs[i + 2] = min( -            costs[i + 2], calc_cost(heights[i], heights[i + 2]) + costs[i] -        ) -    return costs[n - 1] - - -if __name__ == "__main__": -    N = int(eval(input())) -    H = list(map(int, input().split())) -    print((main(N, H))) +N = int(eval(input())) +heights = tuple(map(int, input().split(" "))) +dp = [0] * (N + 1) +dp[1] = 0 +dp[2] = abs(heights[0] - heights[1]) +for hi, i in enumerate(list(range(3, N + 1)), start=2): +    dp[i] = min( +        dp[i - 1] + abs(heights[hi] - heights[hi - 1]), +        dp[i - 2] + abs(heights[hi] - heights[hi - 2]), +    ) +print((dp[N]))