import java.util.*;
import java.io.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }

        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }

        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        }

        public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        }

    }

    public static void main(String[] args) throws IOException, FileNotFoundException {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }

        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }

        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        }

        public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        }

    }

    public static void main(String[] args) throws IOException, FileNotFoundException {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    }
} Main public static void main(String[] args) throws IOException, FileNotFoundException {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    } main {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    } InputReader in = new InputReader(); in new InputReader() PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) int n = in.nextInt(); n in.nextInt() in.nextInt in int[] pts = in.nextIntArr(n); pts in.nextIntArr(n) in.nextIntArr in n int[] dp = new int[n]; dp new int[n] n dp[1] = Math.abs(pts[1] - pts[0]) dp[1] dp 1 Math.abs(pts[1] - pts[0]) Math.abs Math pts[1] - pts[0] pts[1] pts 1 pts[0] pts 0 for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        } int i = 2; int i = 2; i 2 i < dp.length i dp.length dp dp.length i++ i++ i {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        } {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        } int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]); oneback dp[i - 2] + Math.abs(pts[i] - pts[i - 2]) dp[i - 2] dp i - 2 i 2 Math.abs(pts[i] - pts[i - 2]) Math.abs Math pts[i] - pts[i - 2] pts[i] pts i pts[i - 2] pts i - 2 i 2 int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]); twoback dp[i - 1] + Math.abs(pts[i] - pts[i - 1]) dp[i - 1] dp i - 1 i 1 Math.abs(pts[i] - pts[i - 1]) Math.abs Math pts[i] - pts[i - 1] pts[i] pts i pts[i - 1] pts i - 1 i 1 dp[i] = Math.min(oneback, twoback) dp[i] dp i Math.min(oneback, twoback) Math.min Math oneback twoback pw.println(dp[n - 1]) pw.println pw dp[n - 1] dp n - 1 n 1 pw.close() pw.close pw String[] args args static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }

        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }

        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        }

        public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        }

    } InputReader BufferedReader reader; reader StringTokenizer tokenizer; tokenizer public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        } InputReader {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(System.in), 32768) reader new BufferedReader(new InputStreamReader(System.in), 32768) tokenizer = null tokenizer null String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        } nextInt { // reads in the next int
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        } nextLong { // reads in the next long
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        } nextDouble { // reads in the next double
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        } nextIntArr {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        } int[] arr = new int[size]; arr new int[size] size for (int i = 0; i < size; i++) arr[i] = nextInt(); int i = 0; int i = 0; i 0 i < size i size i++ i++ i arr[i] = nextInt(); arr[i] = nextInt() arr[i] arr i nextInt() nextInt return arr; arr int size size public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        } nextLongArr {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        } long[] arr = new long[size]; arr new long[size] size for (int i = 0; i < size; i++) arr[i] = nextLong(); int i = 0; int i = 0; i 0 i < size i size i++ i++ i arr[i] = nextLong(); arr[i] = nextLong() arr[i] arr i nextLong() nextLong return arr; arr int size size public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        } nextDoubleArr {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        } double[] arr = new double[size]; arr new double[size] size for (int i = 0; i < size; i++) arr[i] = nextDouble(); int i = 0; int i = 0; i 0 i < size i size i++ i++ i arr[i] = nextDouble(); arr[i] = nextDouble() arr[i] arr i nextDouble() nextDouble return arr; arr int size size public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }

        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }

        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        }

        public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        }

    }

    public static void main(String[] args) throws IOException, FileNotFoundException {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    }
} public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }

        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }

        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        }

        public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        }

    }

    public static void main(String[] args) throws IOException, FileNotFoundException {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    }
} Main
import java.util.*;
import java.io.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }

        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }

        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] nextLongArr(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) arr[i] = nextLong();
            return arr;
        }

        public double[] nextDoubleArr(int size) {
            double[] arr = new double[size];
            for (int i = 0; i < size; i++) arr[i] = nextDouble();
            return arr;
        }

    }

    public static void main(String[] args) throws IOException, FileNotFoundException {
        InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] pts = in.nextIntArr(n);
        int[] dp = new int[n];

        dp[1] = Math.abs(pts[1] - pts[0]);
        for (int i = 2; i < dp.length; i++) {
            int oneback = dp[i - 2] + Math.abs(pts[i] - pts[i - 2]);
            int twoback = dp[i - 1] + Math.abs(pts[i] - pts[i - 1]);
            dp[i] = Math.min(oneback, twoback);
        }
        // System.out.println(Arrays.toString(dp));

        pw.println(dp[n - 1]);

        pw.close();
    }
}
