import java.util.Scanner;

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

        scanner.close();

    }

  

    public static int frog1(int arr[]) {
        int sol[] = new int[arr.length];
        sol[arr.length - 1] = 0;
        for (int j = arr.length - 2; j >= 0; j--) {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        }
        return sol[0];
    }

   

} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        int arr[] = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(frog1(arr));

        scanner.close();

    }

  

    public static int frog1(int arr[]) {
        int sol[] = new int[arr.length];
        sol[arr.length - 1] = 0;
        for (int j = arr.length - 2; j >= 0; j--) {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        }
        return sol[0];
    }

   

} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        int arr[] = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(frog1(arr));

        scanner.close();

    } main {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        int arr[] = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(frog1(arr));

        scanner.close();

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int size = scanner.nextInt(); size scanner.nextInt() scanner.nextInt scanner int arr[] = new int[size]; arr new int[size] size for (int i = 0; i < size; i++) {
            arr[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            arr[i] = scanner.nextInt();
        } {
            arr[i] = scanner.nextInt();
        } arr[i] = scanner.nextInt() arr[i] arr i scanner.nextInt() scanner.nextInt scanner System.out.println(frog1(arr)) System.out.println System.out System System.out frog1(arr) frog1 arr scanner.close() scanner.close scanner String[] args args public static int frog1(int arr[]) {
        int sol[] = new int[arr.length];
        sol[arr.length - 1] = 0;
        for (int j = arr.length - 2; j >= 0; j--) {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        }
        return sol[0];
    } frog1 {
        int sol[] = new int[arr.length];
        sol[arr.length - 1] = 0;
        for (int j = arr.length - 2; j >= 0; j--) {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        }
        return sol[0];
    } int sol[] = new int[arr.length]; sol new int[arr.length] arr.length arr arr.length sol[arr.length - 1] = 0 sol[arr.length - 1] sol arr.length - 1 arr.length arr arr.length 1 0 for (int j = arr.length - 2; j >= 0; j--) {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        } int j = arr.length - 2; int j = arr.length - 2; j arr.length - 2 arr.length arr arr.length 2 j >= 0 j 0 j-- j-- j {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        } {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        } int cost1 = Integer.MAX_VALUE cost1 Integer.MAX_VALUE Integer Integer.MAX_VALUE cost2 = Integer.MAX_VALUE; cost2 Integer.MAX_VALUE Integer Integer.MAX_VALUE if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            } j + 1 < arr.length j + 1 j 1 arr.length arr arr.length {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            } cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1] cost1 Math.abs(arr[j + 1] - arr[j]) + sol[j + 1] Math.abs(arr[j + 1] - arr[j]) Math.abs Math arr[j + 1] - arr[j] arr[j + 1] arr j + 1 j 1 arr[j] arr j sol[j + 1] sol j + 1 j 1 if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            } j + 2 < arr.length j + 2 j 2 arr.length arr arr.length {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            } cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2] cost2 Math.abs(arr[j + 2] - arr[j]) + sol[j + 2] Math.abs(arr[j + 2] - arr[j]) Math.abs Math arr[j + 2] - arr[j] arr[j + 2] arr j + 2 j 2 arr[j] arr j sol[j + 2] sol j + 2 j 2 sol[j] = Math.min(cost1, cost2) sol[j] sol j Math.min(cost1, cost2) Math.min Math cost1 cost2 return sol[0]; sol[0] sol 0 int arr[] arr
import java.util.Scanner;

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

        scanner.close();

    }

  

    public static int frog1(int arr[]) {
        int sol[] = new int[arr.length];
        sol[arr.length - 1] = 0;
        for (int j = arr.length - 2; j >= 0; j--) {
            int cost1 = Integer.MAX_VALUE, cost2 = Integer.MAX_VALUE;
            if (j + 1 < arr.length) {
                cost1 = Math.abs(arr[j + 1] - arr[j]) + sol[j + 1];
            }
            if (j + 2 < arr.length) {
                cost2 = Math.abs(arr[j + 2] - arr[j]) + sol[j + 2];
            }
            sol[j] = Math.min(cost1, cost2);

        }
        return sol[0];
    }

   

}