import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    }
    static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    }
    static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    }
} Main public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    } main {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    } Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int[] ar=new int[n]; ar new int[n] n for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            ar[i]=in.nextInt();
        } {
            ar[i]=in.nextInt();
        } ar[i]=in.nextInt() ar[i] ar i in.nextInt() in.nextInt in int[] dp=new int[n]; dp new int[n] n Arrays.fill(dp,-1) Arrays.fill Arrays dp -1 1 int ans=go(ar,0,dp); ans go(ar,0,dp) go ar 0 dp System.out.println(ans) System.out.println System.out System System.out ans String args[] args static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    } go {
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    } if (i==ar.length-1){
            return 0;
        } i==ar.length-1 i ar.length-1 ar.length ar ar.length 1 {
            return 0;
        } return 0; 0 if (dp[i]!=-1){
            return dp[i];
        } dp[i]!=-1 dp[i] dp i -1 1 {
            return dp[i];
        } return dp[i]; dp[i] dp i int jump1=Integer.MAX_VALUE jump1 Integer.MAX_VALUE Integer Integer.MAX_VALUE jump2=Integer.MAX_VALUE; jump2 Integer.MAX_VALUE Integer Integer.MAX_VALUE if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        } i+1<ar.length i+1 i 1 ar.length ar ar.length {
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        } jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp) jump1 Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp) Math.abs(ar[i]-ar[i+1]) Math.abs Math ar[i]-ar[i+1] ar[i] ar i ar[i+1] ar i+1 i 1 go(ar,i+1,dp) go ar i+1 i 1 dp if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        } i+2<ar.length i+2 i 2 ar.length ar ar.length {
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        } jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp) jump2 Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp) Math.abs(ar[i]-ar[i+2]) Math.abs Math ar[i]-ar[i+2] ar[i] ar i ar[i+2] ar i+2 i 2 go(ar,i+2,dp) go ar i+2 i 2 dp return dp[i]=Math.min(jump1,jump2); dp[i]=Math.min(jump1,jump2) dp[i] dp i Math.min(jump1,jump2) Math.min Math jump1 jump2 int[] ar ar int i i int[] dp dp public class Main{
    public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    }
    static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    }
} public class Main{
    public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    }
    static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    }
    static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    }
}