import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;

class Main {
    //static {
      //  try {
        //    System.setOut(new PrintStream(new File("output.txt")));
          //  new File("input.txt").createNewFile();
            //System.setIn(new FileInputStream(new File("input.txt")));
        //} catch (Exception e) {
          //  e.printStackTrace();
        //}
    //}
    static FastReader fastReader = new FastReader();
    static BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuffer stringBuffer = new StringBuffer();

    public static void main(String[] args) throws Exception {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    }

    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();
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.BufferedWriter; BufferedWriter java.io import java.io.File; File java.io import java.io.FileInputStream; FileInputStream java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStreamWriter; OutputStreamWriter java.io import java.io.PrintStream; PrintStream java.io import java.util.StringTokenizer; StringTokenizer java.util class Main {
    //static {
      //  try {
        //    System.setOut(new PrintStream(new File("output.txt")));
          //  new File("input.txt").createNewFile();
            //System.setIn(new FileInputStream(new File("input.txt")));
        //} catch (Exception e) {
          //  e.printStackTrace();
        //}
    //}
    static FastReader fastReader = new FastReader();
    static BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuffer stringBuffer = new StringBuffer();

    public static void main(String[] args) throws Exception {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    }

    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();
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
} Main //static {
      //  try {
        //    System.setOut(new PrintStream(new File("output.txt")));
          //  new File("input.txt").createNewFile();
            //System.setIn(new FileInputStream(new File("input.txt")));
        //} catch (Exception e) {
          //  e.printStackTrace();
        //}
    //}
    static FastReader fastReader = new FastReader(); fastReader new FastReader() static BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out)); bufferedWriter new BufferedWriter(new OutputStreamWriter(System.out)) static StringBuffer stringBuffer = new StringBuffer(); stringBuffer new StringBuffer() public static void main(String[] args) throws Exception {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    } main {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    } try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        } catch (Exception e) {
            return;
        } Exception e {
            return;
        } return; {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } int testCases=1; testCases 1 while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            } testCases-- > 0 testCases-- testCases 0 {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            } int n=fastReader.nextInt(); n fastReader.nextInt() fastReader.nextInt fastReader long arr[]=new long[n]; arr new long[n] n for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                    arr[i]=fastReader.nextLong();
                } {
                    arr[i]=fastReader.nextLong();
                } arr[i]=fastReader.nextLong() arr[i] arr i fastReader.nextLong() fastReader.nextLong fastReader long dp[]=new long[n]; dp new long[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(arr[1]-arr[0]) dp[1] dp 1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                } int i=2; int i=2; i 2 i<n i n i++ i++ i {
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                } {
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                } long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]); option1 dp[i-2]+Math.abs(arr[i]-arr[i-2]) dp[i-2] dp i-2 i 2 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]); option2 dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 dp[i]=Math.min(option1,option2) dp[i] dp i Math.min(option1,option2) Math.min Math option1 option2 System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 bufferedWriter.write(stringBuffer.toString()) bufferedWriter.write bufferedWriter stringBuffer.toString() stringBuffer.toString stringBuffer bufferedWriter.flush() bufferedWriter.flush bufferedWriter 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();
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    } 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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str 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 double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;

class Main {
    //static {
      //  try {
        //    System.setOut(new PrintStream(new File("output.txt")));
          //  new File("input.txt").createNewFile();
            //System.setIn(new FileInputStream(new File("input.txt")));
        //} catch (Exception e) {
          //  e.printStackTrace();
        //}
    //}
    static FastReader fastReader = new FastReader();
    static BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuffer stringBuffer = new StringBuffer();

    public static void main(String[] args) throws Exception {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long arr[]=new long[n];
                for(int i=0;i<n;i++){
                    arr[i]=fastReader.nextLong();
                }
                long dp[]=new long[n];
                dp[0]=0;
                dp[1]=Math.abs(arr[1]-arr[0]);
                for(int i=2;i<n;i++){
                    long option1=dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                    long option2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                    dp[i]=Math.min(option1,option2);
                }
                System.out.println(dp[n-1]);
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    }

    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();
        }

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

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

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

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