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 x = 0;
        int y = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        }
        return y;
    }
} 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 x = 0;
        int y = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        }
        return y;
    }
} 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 x = 0;
        int y = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        }
        return y;
    } execute {
        int x = 0;
        int y = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        }
        return y;
    } int x = 0; x 0 int y = Math.abs(arr[1] - arr[0]); y 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++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        } int i = 2; int i = 2; i 2 i < length i length i++ i++ i {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        } {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        } int temp = y; temp y y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1])) y Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1])) Math.min Math x + Math.abs(arr[i] - arr[i - 2]) x 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 y + Math.abs(arr[i] - arr[i - 1]) y 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 x = temp x temp return y; y 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 x = 0;
        int y = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        }
        return y;
    }
}