import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    }


    public static String rString(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

}


 import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    }


    public static String rString(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

} Main final static long MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    } main {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    } FastScanner fs = new FastScanner(); fs new FastScanner() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = fs.nextInt(); n fs.nextInt() fs.nextInt fs int a[] = fs.nextIntArray(n); a fs.nextIntArray(n) fs.nextIntArray fs n int dp[] = new int[n+1]; dp new int[n+1] n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        } {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        } dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE) dp[i] dp i Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE) Math.min Math dp[i-1] + Math.abs(a[i-1] - a[i]) dp[i-1] dp i-1 i 1 Math.abs(a[i-1] - a[i]) Math.abs Math a[i-1] - a[i] a[i-1] a i-1 i 1 a[i] a i i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE i-2 >= 0 i-2 i 2 0 dp[i-2] + Math.abs(a[i-2] - a[i]) dp[i-2] dp i-2 i 2 Math.abs(a[i-2] - a[i]) Math.abs Math a[i-2] - a[i] a[i-2] a i-2 i 2 a[i] a i Integer.MAX_VALUE Integer Integer.MAX_VALUE out.println(dp[n-1]) out.println out dp[n-1] dp n-1 n 1 out.flush() out.flush out out.close() out.close out String[] args args public static String rString(String s) {
        return new StringBuilder(s).reverse().toString();
    } rString {
        return new StringBuilder(s).reverse().toString();
    } return new StringBuilder(s).reverse().toString(); new StringBuilder(s).reverse().toString() new StringBuilder(s).reverse().toString new StringBuilder(s).reverse() new StringBuilder(s).reverse new StringBuilder(s) String s s static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    } FastScanner BufferedReader br; br StringTokenizer st; st public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        } FastScanner {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        } try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } Exception e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) st = new StringTokenizer("") st new StringTokenizer("") public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        } next {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        } if (st.hasMoreTokens())
                return st.nextToken(); st.hasMoreTokens() st.hasMoreTokens st return st.nextToken(); st.nextToken() st.nextToken st try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } Exception 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 public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        } nextLine {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        } String line = ""; line "" try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } Exception e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                line = br.readLine();
            } line = br.readLine() line br.readLine() br.readLine br return line; line public char nextChar() {
            return next().charAt(0);
        } nextChar {
            return next().charAt(0);
        } return next().charAt(0); next().charAt(0) next().charAt next() next 0 public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        } nextIntegerArray {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        } Integer[] a = new Integer[n]; a new Integer[n] n for (int i = 0; i < n; i++)
                a[i] = nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextInt(); a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        } nextIntArray {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        } int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++)
                a[i] = nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextInt(); a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } nextLongArray {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } long[] a = new long[n]; a new long[n] n for (int i = 0; i < n; i++)
                a[i] = nextLong(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextLong(); a[i] = nextLong() a[i] a i nextLong() nextLong return a; a int n n public char[] nextCharArray() {
            return nextLine().toCharArray();
        } nextCharArray {
            return nextLine().toCharArray();
        } return nextLine().toCharArray(); nextLine().toCharArray() nextLine().toCharArray nextLine() nextLine public class Main {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    }


    public static String rString(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

} public class Main {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    }


    public static String rString(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int a[] = fs.nextIntArray(n);

        int dp[] = new int[n+1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(a[i-1] - a[i]), i-2 >= 0 ?  dp[i-2] + Math.abs(a[i-2] - a[i]) : Integer.MAX_VALUE);
        }

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

        out.flush();
        out.close();
    }


    public static String rString(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

}



