import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
        public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
} Main public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        } main {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.nextLine()); N Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner int[] costs = new int[N]; costs new int[N] N int[] cache = new int[N]; cache new int[N] N String[] c = scanner.nextLine().split(" "); c scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                } {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                } costs[i] = Integer.parseInt(c[i]) costs[i] costs i Integer.parseInt(c[i]) Integer.parseInt Integer c[i] c i cache[i] = 1000000 cache[i] cache i 1000000 cache[0] = 0 cache[0] cache 0 0 cache[1] = Math.abs(costs[0]-costs[1]) cache[1] cache 1 Math.abs(costs[0]-costs[1]) Math.abs Math costs[0]-costs[1] costs[0] costs 0 costs[1] costs 1 System.out.println(jump(costs, 2, cache)) System.out.println System.out System System.out jump(costs, 2, cache) jump costs 2 cache return; String[] args args private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        } jump {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        } for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                } int i = 2 ; int i = 2 ; i 2 i < costs.length i costs.length costs costs.length i++ i++ i {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                } {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                } cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2])) cache[i] cache i Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2])) Math.min Math cache[i-1]+(Math.abs(costs[i] - costs[i-1])) cache[i-1] cache i-1 i 1 (Math.abs(costs[i] - costs[i-1])) Math.abs Math costs[i] - costs[i-1] costs[i] costs i costs[i-1] costs i-1 i 1 cache[i-2]+Math.abs(costs[i] - costs[i-2]) cache[i-2] cache i-2 i 2 Math.abs(costs[i] - costs[i-2]) Math.abs Math costs[i] - costs[i-2] costs[i] costs i costs[i-2] costs i-2 i 2 return cache[costs.length-1]; cache[costs.length-1] cache costs.length-1 costs.length costs costs.length 1 int[] costs costs int k k int[] cache cache public class Main {
        public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
} public class Main {
        public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
}