import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
} Main static InputStreamReader r; r public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    } main {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    } r = new InputStreamReader(System.in) r new InputStreamReader(System.in) int N = nextInt(); N nextInt() nextInt int[] h = new int[N+5]; h new int[N+5] N+5 N 5 for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            h[i] = nextInt();
        } {
            h[i] = nextInt();
        } h[i] = nextInt() h[i] h i nextInt() nextInt int[] DP = new int[N+5]; DP new int[N+5] N+5 N 5 Arrays.fill(DP, Integer.MAX_VALUE) Arrays.fill Arrays DP Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        } {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        } if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            } i == 1 i 1 {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            } DP[i+1] = Math.abs(h[i+1] - h[i]) DP[i+1] DP i+1 i 1 Math.abs(h[i+1] - h[i]) Math.abs Math h[i+1] - h[i] h[i+1] h i+1 i 1 h[i] h i DP[i+2] = Math.abs(h[i+2] - h[i]) DP[i+2] DP i+2 i 2 Math.abs(h[i+2] - h[i]) Math.abs Math h[i+2] - h[i] h[i+2] h i+2 i 2 h[i] h i continue; DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i])) DP[i+1] DP i+1 i 1 Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i])) Math.min Math DP[i+1] DP i+1 i 1 DP[i] + Math.abs(h[i+1] - h[i]) DP[i] DP i Math.abs(h[i+1] - h[i]) Math.abs Math h[i+1] - h[i] h[i+1] h i+1 i 1 h[i] h i DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i])) DP[i+2] DP i+2 i 2 Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i])) Math.min Math DP[i+2] DP i+2 i 2 DP[i] + Math.abs(h[i+2] - h[i]) DP[i] DP i Math.abs(h[i+2] - h[i]) Math.abs Math h[i+2] - h[i] h[i+2] h i+2 i 2 h[i] h i System.out.println(DP[N]) System.out.println System.out System System.out DP[N] DP N String[] args args public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    } nextString {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    } String res = ""; res "" while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        } true {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        } int c = r.read(); c r.read() r.read r if (c == 32 || c == 10 || c == -1) {
                break;
            } c == 32 || c == 10 || c == -1 c == 32 || c == 10 || c == -1 c == 32 c 32 c == 10 c 10 c == -1 c -1 1 {
                break;
            } break; res += (char)c res (char)c return res; res public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    } nextInt {
        return Integer.parseInt(nextString());
    } return Integer.parseInt(nextString()); Integer.parseInt(nextString()) Integer.parseInt Integer nextString() nextString public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    } nextLong {
        return Long.parseLong(nextString());
    } return Long.parseLong(nextString()); Long.parseLong(nextString()) Long.parseLong Long nextString() nextString public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
} public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
} Main
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int[] h = new int[N+5];
        for (int i = 1; i <= N; i++) {
            h[i] = nextInt();
        }

        int[] DP = new int[N+5];
        Arrays.fill(DP, Integer.MAX_VALUE);
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                DP[i+1] = Math.abs(h[i+1] - h[i]);
                DP[i+2] = Math.abs(h[i+2] - h[i]);
                continue;
            }
            DP[i+1] = Math.min(DP[i+1], DP[i] + Math.abs(h[i+1] - h[i]));
            DP[i+2] = Math.min(DP[i+2], DP[i] + Math.abs(h[i+2] - h[i]));
        }

        System.out.println(DP[N]);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
}