//package atcoderdp;
import java.util.*;
 class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        }
        System.out.println(find(a,n));
    }
    public static int find(int a[],int n){
        if(n<2)
            return 0;
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        //System.out.println(Arrays.toString(dp));
        for (int i = 2; i <n ; i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        }
        //System.out.println(Arrays.toString(dp));
        return dp[n-1];
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        }
        System.out.println(find(a,n));
    }
    public static int find(int a[],int n){
        if(n<2)
            return 0;
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        //System.out.println(Arrays.toString(dp));
        for (int i = 2; i <n ; i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        }
        //System.out.println(Arrays.toString(dp));
        return dp[n-1];
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        }
        System.out.println(find(a,n));
    } main {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        }
        System.out.println(find(a,n));
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int a[]=new int[n]; a new int[n] n for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        } int i = 0; int i = 0; i 0 i <n i n i++ i++ i {
            a[i] = s.nextInt();
        } {
            a[i] = s.nextInt();
        } a[i] = s.nextInt() a[i] a i s.nextInt() s.nextInt s System.out.println(find(a,n)) System.out.println System.out System System.out find(a,n) find a n String[] args args public static int find(int a[],int n){
        if(n<2)
            return 0;
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        //System.out.println(Arrays.toString(dp));
        for (int i = 2; i <n ; i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        }
        //System.out.println(Arrays.toString(dp));
        return dp[n-1];
    } find {
        if(n<2)
            return 0;
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        //System.out.println(Arrays.toString(dp));
        for (int i = 2; i <n ; i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        }
        //System.out.println(Arrays.toString(dp));
        return dp[n-1];
    } if(n<2)
            return 0; n<2 n 2 return 0; 0 int dp[]=new int[n]; dp new int[n] n Arrays.fill(dp,Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(a[1]-a[0]) dp[1] dp 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++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        } int i = 2; int i = 2; i 2 i <n i n i++ i++ i {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        } {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        } dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i])) dp[i] dp i Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i])) Math.min Math dp[i-1]+Math.abs(a[i-1]-a[i]) dp[i-1] dp i-1 i 1 Math.abs(a[i-1]-a[i]) Math.abs Math a[i-1]-a[i] a[i-1] a i-1 i 1 a[i] a i dp[i-2]+Math.abs(a[i-2]-a[i]) dp[i-2] dp i-2 i 2 Math.abs(a[i-2]-a[i]) Math.abs Math a[i-2]-a[i] a[i-2] a i-2 i 2 a[i] a i return dp[n-1]; dp[n-1] dp n-1 n 1 int a[] a int n n
//package atcoderdp;
import java.util.*;
 class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        }
        System.out.println(find(a,n));
    }
    public static int find(int a[],int n){
        if(n<2)
            return 0;
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        //System.out.println(Arrays.toString(dp));
        for (int i = 2; i <n ; i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        }
        //System.out.println(Arrays.toString(dp));
        return dp[n-1];
    }
}
