import java.util.Arrays;
import java.util.Scanner;

public class Main {



    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    }

    private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    }
    

}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz