import java.util.*;

class Main {
    public static long solve(int arr[], int n) {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        }

        return ans[n];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(solve(arr, n));
    }
} import java.util.*; util.* java class Main {
    public static long solve(int arr[], int n) {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        }

        return ans[n];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(solve(arr, n));
    }
} Main public static long solve(int arr[], int n) {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        }

        return ans[n];
    } solve {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        }

        return ans[n];
    } long ans[] = new long[n + 1]; ans new long[n + 1] n + 1 n 1 ans[1] = 0 ans[1] ans 1 0 ans[2] = Math.abs(arr[1] - arr[2]) ans[2] ans 2 Math.abs(arr[1] - arr[2]) Math.abs Math arr[1] - arr[2] arr[1] arr 1 arr[2] arr 2 for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        } int i = 3; int i = 3; i 3 i <= n i n i++ i++ i {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        } {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        } ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]) ans[i] ans i Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]) Math.min Math Math.abs(arr[i] - arr[i - 1]) + ans[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 ans[i - 1] ans i - 1 i 1 Math.abs(arr[i] - arr[i - 2]) + ans[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 ans[i - 2] ans i - 2 i 2 return ans[n]; ans[n] ans n int arr[] arr int n n public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

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

        int arr[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(solve(arr, n));
    } 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 + 1]; arr new int[n + 1] n + 1 n 1 for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        } int i = 1; int i = 1; i 1 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(solve(arr, n)) System.out.println System.out System System.out solve(arr, n) solve arr n String[] args args
import java.util.*;

class Main {
    public static long solve(int arr[], int n) {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        }

        return ans[n];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(solve(arr, n));
    }
}