import java.util.Scanner;

class Main {

    static int solve(int[] inputs){
        int[] dp = new int[inputs.length];
        dp[0] = 0;
        dp[1] = Math.abs(inputs[0] - inputs[1]);

        for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2]));

        return dp[dp.length - 1];
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); scanner.nextLine();
        int[] inputs = new int[n];
        for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt();

        System.out.println(Main.solve(inputs));
        scanner.close();
    }
} import java.util.Scanner; Scanner java.util class Main {

    static int solve(int[] inputs){
        int[] dp = new int[inputs.length];
        dp[0] = 0;
        dp[1] = Math.abs(inputs[0] - inputs[1]);

        for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2]));

        return dp[dp.length - 1];
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); scanner.nextLine();
        int[] inputs = new int[n];
        for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt();

        System.out.println(Main.solve(inputs));
        scanner.close();
    }
} Main static int solve(int[] inputs){
        int[] dp = new int[inputs.length];
        dp[0] = 0;
        dp[1] = Math.abs(inputs[0] - inputs[1]);

        for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2]));

        return dp[dp.length - 1];
    } solve {
        int[] dp = new int[inputs.length];
        dp[0] = 0;
        dp[1] = Math.abs(inputs[0] - inputs[1]);

        for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2]));

        return dp[dp.length - 1];
    } int[] dp = new int[inputs.length]; dp new int[inputs.length] inputs.length inputs inputs.length dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(inputs[0] - inputs[1]) dp[1] dp 1 Math.abs(inputs[0] - inputs[1]) Math.abs Math inputs[0] - inputs[1] inputs[0] inputs 0 inputs[1] inputs 1 for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2])); int i = 2; int i = 2; i 2 i < dp.length i dp.length dp dp.length i++ i++ i dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2])); dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2])) dp[i] dp i Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2])) Math.min Math dp[i-1] + Math.abs(inputs[i] - inputs[i-1]) dp[i-1] dp i-1 i 1 Math.abs(inputs[i] - inputs[i-1]) Math.abs Math inputs[i] - inputs[i-1] inputs[i] inputs i inputs[i-1] inputs i-1 i 1 dp[i-2] + Math.abs(inputs[i] - inputs[i-2]) dp[i-2] dp i-2 i 2 Math.abs(inputs[i] - inputs[i-2]) Math.abs Math inputs[i] - inputs[i-2] inputs[i] inputs i inputs[i-2] inputs i-2 i 2 return dp[dp.length - 1]; dp[dp.length - 1] dp dp.length - 1 dp.length dp dp.length 1 int[] inputs inputs public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); scanner.nextLine();
        int[] inputs = new int[n];
        for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt();

        System.out.println(Main.solve(inputs));
        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); scanner.nextLine();
        int[] inputs = new int[n];
        for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt();

        System.out.println(Main.solve(inputs));
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner int[] inputs = new int[n]; inputs new int[n] n for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i inputs[i] = scanner.nextInt(); inputs[i] = scanner.nextInt() inputs[i] inputs i scanner.nextInt() scanner.nextInt scanner System.out.println(Main.solve(inputs)) System.out.println System.out System System.out Main.solve(inputs) Main.solve Main inputs scanner.close() scanner.close scanner String[] args args
import java.util.Scanner;

class Main {

    static int solve(int[] inputs){
        int[] dp = new int[inputs.length];
        dp[0] = 0;
        dp[1] = Math.abs(inputs[0] - inputs[1]);

        for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2]));

        return dp[dp.length - 1];
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); scanner.nextLine();
        int[] inputs = new int[n];
        for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt();

        System.out.println(Main.solve(inputs));
        scanner.close();
    }
}