import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        System.out.println(execute(arr, n));
        sc.close();
    }

    private static int execute(int[] arr, int length) {
        int[] dp = new int[length];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        }
        return dp[length - 1];
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        System.out.println(execute(arr, n));
        sc.close();
    }

    private static int execute(int[] arr, int length) {
        int[] dp = new int[length];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

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

        System.out.println(execute(arr, n));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        System.out.println(execute(arr, n));
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc System.out.println(execute(arr, n)) System.out.println System.out System System.out execute(arr, n) execute arr n sc.close() sc.close sc String[] args args private static int execute(int[] arr, int length) {
        int[] dp = new int[length];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        }
        return dp[length - 1];
    } execute {
        int[] dp = new int[length];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        }
        return dp[length - 1];
    } int[] dp = new int[length]; dp new int[length] length dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(arr[1] - arr[0]) dp[1] dp 1 Math.abs(arr[1] - arr[0]) Math.abs Math arr[1] - arr[0] arr[1] arr 1 arr[0] arr 0 for (int i = 2; i < length; i++) {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        } int i = 2; int i = 2; i 2 i < length i length i++ i++ i {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        } {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        } dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1])) dp[i] dp i Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1])) Math.min Math dp[i - 2] + Math.abs(arr[i] - arr[i - 2]) dp[i - 2] dp i - 2 i 2 Math.abs(arr[i] - arr[i - 2]) Math.abs Math arr[i] - arr[i - 2] arr[i] arr i arr[i - 2] arr i - 2 i 2 dp[i - 1] + Math.abs(arr[i] - arr[i - 1]) dp[i - 1] dp i - 1 i 1 Math.abs(arr[i] - arr[i - 1]) Math.abs Math arr[i] - arr[i - 1] arr[i] arr i arr[i - 1] arr i - 1 i 1 return dp[length - 1]; dp[length - 1] dp length - 1 length 1 int[] arr arr int length length
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        System.out.println(execute(arr, n));
        sc.close();
    }

    private static int execute(int[] arr, int length) {
        int[] dp = new int[length];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {

            dp[i] = Math.min(dp[i - 2] + Math.abs(arr[i] - arr[i - 2]), dp[i - 1] + Math.abs(arr[i] - arr[i - 1]));

        }
        return dp[length - 1];
    }
}
