
///.....FROG-1....///

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

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return (Integer.parseInt(next()));
        }

        long nextLong() {
            return (Long.parseLong(next()));
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        System.out.println(dp[n-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 class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return (Integer.parseInt(next()));
        }

        long nextLong() {
            return (Long.parseLong(next()));
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        System.out.println(dp[n-1]);
    }
} Main public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        System.out.println(dp[n-1]);
    } main {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        System.out.println(dp[n-1]);
    } FastReader in = new FastReader(); in new FastReader() int n = in.nextInt(); n in.nextInt() in.nextInt in int h[] = new int[n]; h new int[n] n for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            h[i] = in.nextInt();
        } {
            h[i] = in.nextInt();
        } h[i] = in.nextInt() h[i] h i in.nextInt() in.nextInt in int dp[] = new int[n]; dp new int[n] n dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(h[1] - h[0]) dp[1] dp 1 Math.abs(h[1] - h[0]) Math.abs Math h[1] - h[0] h[1] h 1 h[0] h 0 for (int i = 2; i < n; i++) {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        } {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        } dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]) dp[i] dp i Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]) Math.min Math Math.abs(h[i] - h[i - 1]) + dp[i - 1] Math.abs(h[i] - h[i - 1]) Math.abs Math h[i] - h[i - 1] h[i] h i h[i - 1] h i - 1 i 1 dp[i - 1] dp i - 1 i 1 Math.abs(h[i] - h[i - 2]) + dp[i - 2] Math.abs(h[i] - h[i - 2]) Math.abs Math h[i] - h[i - 2] h[i] h i h[i - 2] h i - 2 i 2 dp[i - 2] dp i - 2 i 2 System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 String[] args args static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return (Integer.parseInt(next()));
        }

        long nextLong() {
            return (Long.parseLong(next()));
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastReader {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return (Integer.parseInt(next()));
        } nextInt {
            return (Integer.parseInt(next()));
        } return (Integer.parseInt(next())); (Integer.parseInt(next())) Integer.parseInt Integer next() next long nextLong() {
            return (Long.parseLong(next()));
        } nextLong {
            return (Long.parseLong(next()));
        } return (Long.parseLong(next())); (Long.parseLong(next())) Long.parseLong Long next() next String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        } nextLine {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        } String s = ""; s "" try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                s = br.readLine();
            } s = br.readLine() s br.readLine() br.readLine br return s; s

///.....FROG-1....///

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

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return (Integer.parseInt(next()));
        }

        long nextLong() {
            return (Long.parseLong(next()));
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
           // System.out.println(Math.abs(h[i] - h[i - 1]) + dp[i - 1]+" "+Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        System.out.println(dp[n-1]);
    }
}
