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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.PrintWriter; PrintWriter 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 java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    } main {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    } BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in)); br new BufferedReader(new java.io.InputStreamReader(System.in)) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st String[] input_str_array = br.readLine().split(" "); input_str_array br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] input_array = new int[N]; input_array new int[N] N for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        } {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        } input_array[i] = Integer.parseInt(input_str_array[i]) input_array[i] input_array i Integer.parseInt(input_str_array[i]) Integer.parseInt Integer input_str_array[i] input_str_array i int[] dp = new int[N]; dp new int[N] N dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(input_array[1] - input_array[0]) dp[1] dp 1 Math.abs(input_array[1] - input_array[0]) Math.abs Math input_array[1] - input_array[0] input_array[1] input_array 1 input_array[0] input_array 0 for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        } int i = 2; int i = 2; i 2 i < N i N i++ i++ i {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        } {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        } if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            } dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1])) dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) dp[i-2] dp i-2 i 2 (Math.abs(input_array[i] - input_array[i-2])) Math.abs Math input_array[i] - input_array[i-2] input_array[i] input_array i input_array[i-2] input_array i-2 i 2 dp[i-1] + (Math.abs(input_array[i] - input_array[i-1])) dp[i-1] dp i-1 i 1 (Math.abs(input_array[i] - input_array[i-1])) Math.abs Math input_array[i] - input_array[i-1] input_array[i] input_array i input_array[i-1] input_array i-1 i 1 {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1])) dp[i] dp i dp[i-1] + (Math.abs(input_array[i] - input_array[i-1])) dp[i-1] dp i-1 i 1 (Math.abs(input_array[i] - input_array[i-1])) Math.abs Math input_array[i] - input_array[i-1] input_array[i] input_array i input_array[i-1] input_array i-1 i 1 {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            } dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) dp[i] dp i dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) dp[i-2] dp i-2 i 2 (Math.abs(input_array[i] - input_array[i-2])) Math.abs Math input_array[i] - input_array[i-2] input_array[i] input_array i input_array[i-2] input_array i-2 i 2 pw.println(dp[N-1]) pw.println pw dp[N-1] dp N-1 N 1 pw.close() pw.close pw br.close() br.close br String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_str_array = br.readLine().split(" ");
        int[] input_array = new int[N];

        for(int i = 0; i < N; i++) {
            input_array[i] = Integer.parseInt(input_str_array[i]);
        }

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(input_array[1] - input_array[0]);

        for(int i = 2; i < N; i++) {

            if(dp[i-2] + (Math.abs(input_array[i] - input_array[i-2])) > dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]))) {
                dp[i] = dp[i-1] + (Math.abs(input_array[i] - input_array[i-1]));
            } else {
                dp[i] = dp[i-2] + (Math.abs(input_array[i] - input_array[i-2]));
            }
            
        }

        pw.println(dp[N-1]);
        
        pw.close();
        br.close();
    }
}
