import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    }
} Main public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    } main {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    } Scanner ob=new Scanner(System.in); ob new Scanner(System.in) int n=ob.nextInt(); n ob.nextInt() ob.nextInt ob int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            a[i]=ob.nextInt();
        } {
            a[i]=ob.nextInt();
        } a[i]=ob.nextInt() a[i] a i ob.nextInt() ob.nextInt ob int arr[]=new int[n]; arr new int[n] n arr[0]=0 arr[0] arr 0 0 arr[1]=Math.abs(a[1]-a[0]) arr[1] arr 1 Math.abs(a[1]-a[0]) Math.abs Math a[1]-a[0] a[1] a 1 a[0] a 0 for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        } int i=2; int i=2; i 2 i<n i n i++ i++ i {
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        } {
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        } arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1])) arr[i] arr i Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1])) Math.min Math arr[i-2]+Math.abs(a[i]-a[i-2]) arr[i-2] arr i-2 i 2 Math.abs(a[i]-a[i-2]) Math.abs Math a[i]-a[i-2] a[i] a i a[i-2] a i-2 i 2 arr[i-1]+Math.abs(a[i]-a[i-1]) arr[i-1] arr i-1 i 1 Math.abs(a[i]-a[i-1]) Math.abs Math a[i]-a[i-1] a[i] a i a[i-1] a i-1 i 1 System.out.println(arr[n-1]) System.out.println System.out System System.out arr[n-1] arr n-1 n 1 ob.close() ob.close ob String[] args args public class Main{
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    }
} public class Main{
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    }
}