//package AtCoderDp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    }
} Main public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    } main {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int h[]=new int[n+1]; h new int[n+1] n+1 n 1 StringTokenizer st=new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) long dp[]=new long[n+1]; dp new long[n+1] n+1 n 1 for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
            h[i]=Integer.parseInt(st.nextToken());
        } {
            h[i]=Integer.parseInt(st.nextToken());
        } h[i]=Integer.parseInt(st.nextToken()) h[i] h i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st dp[n-1]=Math.abs(h[n]-h[n-1]) dp[n-1] dp n-1 n 1 Math.abs(h[n]-h[n-1]) Math.abs Math h[n]-h[n-1] h[n] h n h[n-1] h n-1 n 1 for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        } int i=n-2; int i=n-2; i n-2 n 2 i>=1 i 1 i-- i-- i {
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        } {
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        } dp[i]=Long.MAX_VALUE dp[i] dp i Long.MAX_VALUE Long Long.MAX_VALUE for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            } int j=i+1; int j=i+1; j i+1 i 1 j<=i+2 j i+2 i 2 j++ j++ j {
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            } {
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            } dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i])) dp[i] dp i Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i])) Math.min Math dp[i] dp i dp[j]+Math.abs(h[j]-h[i]) dp[j] dp j Math.abs(h[j]-h[i]) Math.abs Math h[j]-h[i] h[j] h j h[i] h i System.out.println(dp[1]) System.out.println System.out System System.out dp[1] dp 1 String[] args args public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    }
} public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    }
} Main
//package AtCoderDp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    }
}
