import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    }


}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

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

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStream; OutputStream 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 Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    }


} Main public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    } main {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    } ModScanner ms = new ModScanner(); ms new ModScanner() OutputStream outputStream = System.out; outputStream System.out System System.out PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) int n = ms.nextInt(); n ms.nextInt() ms.nextInt ms int[] heights = new int[n]; heights new int[n] n for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            heights[i] = ms.nextInt();
        } {
            heights[i] = ms.nextInt();
        } heights[i] = ms.nextInt() heights[i] heights i ms.nextInt() ms.nextInt ms int[] dp = new int[n]; dp new int[n] n dp[1] = Math.abs(heights[0] - heights[1]) dp[1] dp 1 Math.abs(heights[0] - heights[1]) Math.abs Math heights[0] - heights[1] heights[0] heights 0 heights[1] heights 1 for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        } {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        } dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i])) dp[i] dp i Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i])) Math.min Math dp[i - 2] + Math.abs(heights[i - 2] - heights[i]) dp[i - 2] dp i - 2 i 2 Math.abs(heights[i - 2] - heights[i]) Math.abs Math heights[i - 2] - heights[i] heights[i - 2] heights i - 2 i 2 heights[i] heights i dp[i - 1] + Math.abs(heights[i - 1] - heights[i]) dp[i - 1] dp i - 1 i 1 Math.abs(heights[i - 1] - heights[i]) Math.abs Math heights[i - 1] - heights[i] heights[i - 1] heights i - 1 i 1 heights[i] heights i out.println(dp[n - 1]) out.println out dp[n - 1] dp n - 1 n 1 out.close() out.close out String[] args args class ModScanner {

    BufferedReader br;
    StringTokenizer st;

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

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

} ModScanner BufferedReader br; br StringTokenizer st; st public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    } ModScanner {
        br = new BufferedReader(new InputStreamReader(System.in));
    } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    } nextToken {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    } while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
            st = new StringTokenizer(br.readLine());

        } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st String nextString() throws Exception {
        return br.readLine();
    } nextString {
        return br.readLine();
    } return br.readLine(); br.readLine() br.readLine br int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    } nextInt {
        return Integer.parseInt(nextToken());
    } return Integer.parseInt(nextToken()); Integer.parseInt(nextToken()) Integer.parseInt Integer nextToken() nextToken long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    } nextLong {
        return Long.parseLong(nextToken());
    } return Long.parseLong(nextToken()); Long.parseLong(nextToken()) Long.parseLong Long nextToken() nextToken double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    } nextDouble {
        return Double.parseDouble(nextToken());
    } return Double.parseDouble(nextToken()); Double.parseDouble(nextToken()) Double.parseDouble Double nextToken() nextToken public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    }


} public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    }


} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        dp[1] = Math.abs(heights[0] - heights[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 2] + Math.abs(heights[i - 2] - heights[i]),
                    dp[i - 1] + Math.abs(heights[i - 1] - heights[i]));
        }
        out.println(dp[n - 1]);
        out.close();
    }


}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

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

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}
