import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc ArrayList<Integer> asiba = new ArrayList<Integer>(); asiba new ArrayList<Integer>() for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            asiba.add(sc.nextInt());
        } {
            asiba.add(sc.nextInt());
        } asiba.add(sc.nextInt()) asiba.add asiba sc.nextInt() sc.nextInt sc ArrayList<Integer> cost = new ArrayList<Integer>(); cost new ArrayList<Integer>() cost.add(0) cost.add cost 0 cost.add(Math.abs(asiba.get(1) - asiba.get(0))) cost.add cost Math.abs(asiba.get(1) - asiba.get(0)) Math.abs Math asiba.get(1) - asiba.get(0) asiba.get(1) asiba.get asiba 1 asiba.get(0) asiba.get asiba 0 for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        } int i = 2; int i = 2; i 2 i < N i N i++ i++ i {
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        } {
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        } int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1); MAX Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1) Math.abs(asiba.get(i) - asiba.get(i - 1)) Math.abs Math asiba.get(i) - asiba.get(i - 1) asiba.get(i) asiba.get asiba i asiba.get(i - 1) asiba.get asiba i - 1 i 1 cost.get(i-1) cost.get cost i-1 i 1 int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2); MAX2 Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2) Math.abs(asiba.get(i) - asiba.get(i - 2)) Math.abs Math asiba.get(i) - asiba.get(i - 2) asiba.get(i) asiba.get asiba i asiba.get(i - 2) asiba.get asiba i - 2 i 2 cost.get(i-2) cost.get cost i-2 i 2 if(MAX > MAX2) MAX = MAX2; MAX > MAX2 MAX MAX2 MAX = MAX2 MAX MAX2 cost.add(MAX) cost.add cost MAX System.out.println(cost.get(N -1)) System.out.println System.out System System.out cost.get(N -1) cost.get cost N -1 N 1 String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    }
} public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    }
} Main
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> asiba = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            asiba.add(sc.nextInt());
        }
        ArrayList<Integer> cost = new ArrayList<Integer>();
        cost.add(0);
        cost.add(Math.abs(asiba.get(1) - asiba.get(0)));
        for(int i = 2; i < N; i++){
            int MAX = Math.abs(asiba.get(i) - asiba.get(i - 1)) + cost.get(i-1);
            int MAX2 = Math.abs(asiba.get(i) - asiba.get(i - 2)) + cost.get(i-2);
            if(MAX > MAX2) MAX = MAX2;
            cost.add(MAX);
        }
        System.out.println(cost.get(N -1));
        
    }
}