import java.util.*;
import java.util.Arrays;

public class Main {
    public static long a = (long)Math.pow(2, 60);
    public static long[] lst;
    public static long[] height;
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    }
    static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    }
} import java.util.*; util.* java import java.util.Arrays; Arrays java.util public class Main {
    public static long a = (long)Math.pow(2, 60);
    public static long[] lst;
    public static long[] height;
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    }
    static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    }
} Main public static long a = (long)Math.pow(2, 60); a (long)Math.pow(2, 60) Math.pow Math 2 60 public static long[] lst; lst public static long[] height; height public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    } main {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc lst = new long[N] lst new long[N] N Arrays.fill(lst, a) Arrays.fill Arrays lst a height = new long[N] height new long[N] N for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            height[i] = sc.nextInt();
        } {
            height[i] = sc.nextInt();
        } height[i] = sc.nextInt() height[i] height i sc.nextInt() sc.nextInt sc System.out.println(tilAns(N)) System.out.println System.out System System.out tilAns(N) tilAns N String[] args args static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    } tilAns {
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    } if (lst[n-1] != a) {
            return lst[n-1];
        } lst[n-1] != a lst[n-1] lst n-1 n 1 a {
            return lst[n-1];
        } return lst[n-1]; lst[n-1] lst n-1 n 1 if (n == 1) {
            lst[0] = 0;
            return 0;
        } n == 1 n 1 {
            lst[0] = 0;
            return 0;
        } lst[0] = 0 lst[0] lst 0 0 return 0; 0 if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        } n == 2 n 2 {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        } lst[1] = tilAns(1) + Math.abs(height[1] - height[0]) lst[1] lst 1 tilAns(1) + Math.abs(height[1] - height[0]) tilAns(1) tilAns 1 Math.abs(height[1] - height[0]) Math.abs Math height[1] - height[0] height[1] height 1 height[0] height 0 return lst[1]; lst[1] lst 1 lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2])) lst[n-1] lst n-1 n 1 Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2])) Math.min Math tilAns(n-2) + Math.abs(height[n-1] - height[n-3]) tilAns(n-2) tilAns n-2 n 2 Math.abs(height[n-1] - height[n-3]) Math.abs Math height[n-1] - height[n-3] height[n-1] height n-1 n 1 height[n-3] height n-3 n 3 tilAns(n-1) + Math.abs(height[n-1] - height[n-2]) tilAns(n-1) tilAns n-1 n 1 Math.abs(height[n-1] - height[n-2]) Math.abs Math height[n-1] - height[n-2] height[n-1] height n-1 n 1 height[n-2] height n-2 n 2 return lst[n-1]; lst[n-1] lst n-1 n 1 int n n public class Main {
    public static long a = (long)Math.pow(2, 60);
    public static long[] lst;
    public static long[] height;
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    }
    static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    }
} public class Main {
    public static long a = (long)Math.pow(2, 60);
    public static long[] lst;
    public static long[] height;
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    }
    static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    }
} Main
import java.util.*;
import java.util.Arrays;

public class Main {
    public static long a = (long)Math.pow(2, 60);
    public static long[] lst;
    public static long[] height;
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    }
    static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    }
}
