import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] arr = new int[n]; arr new int[n] n for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        } int i=0 ; int i=0 ; i 0 i<n i n ++i ++i i {
            arr[i] = scanner.nextInt();
        } {
            arr[i] = scanner.nextInt();
        } arr[i] = scanner.nextInt() arr[i] arr i scanner.nextInt() scanner.nextInt scanner int s0 = 0 s0 0 s1 = Math.abs(arr[1]-arr[0]); s1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 int res=s1; res s1 for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        } int i=2; int i=2; i 2 i<n i n ++i ++i i {
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        } {
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        } res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1])) res Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1])) Math.min Math s0+Math.abs(arr[i]-arr[i-2]) s0 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 s1+Math.abs(arr[i]-arr[i-1]) s1 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 s0 =s1 s0 s1 s1=res s1 res System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    }
}
