
import java.util.*;

public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 2;
    public static int[] h = new int[100001];
    public static long[] dp = new long[100001];
    public final static long oo = 10000000000l;

    public static long solve(int idx) {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    }

} import java.util.*; util.* java public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 2;
    public static int[] h = new int[100001];
    public static long[] dp = new long[100001];
    public final static long oo = 10000000000l;

    public static long solve(int idx) {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    }

} Main public static Scanner in = new Scanner(System.in); in new Scanner(System.in) public static int n = 0 n 0 k = 2; k 2 public static int[] h = new int[100001]; h new int[100001] 100001 public static long[] dp = new long[100001]; dp new long[100001] 100001 public final static long oo = 10000000000l; oo 10000000000l public static long solve(int idx) {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    } solve {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    } if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        } idx == n - 1 idx n - 1 n 1 {
            return 0;
        } return 0; 0 {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        } if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            } dp[idx] == -1 dp[idx] dp idx -1 1 {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]); c1 solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]) solve(idx + 1) solve idx + 1 idx 1 Math.abs(h[idx] - h[idx + 1]) Math.abs Math h[idx] - h[idx + 1] h[idx] h idx h[idx + 1] h idx + 1 idx 1 long c2 = oo; c2 oo if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                } n - idx > 2 n - idx n idx 2 {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                } c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]) c2 solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]) solve(idx + 2) solve idx + 2 idx 2 Math.abs(h[idx] - h[idx + 2]) Math.abs Math h[idx] - h[idx + 2] h[idx] h idx h[idx + 2] h idx + 2 idx 2 return dp[idx] = Math.min(c1, c2); dp[idx] = Math.min(c1, c2) dp[idx] dp idx Math.min(c1, c2) Math.min Math c1 c2 {
                return dp[idx];
            } return dp[idx]; dp[idx] dp idx int idx idx public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    } main {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    } for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        } int i = 0; int i = 0; i 0 i < 100001 i 100001 i++ i++ i {
            dp[i] = -1;
        } {
            dp[i] = -1;
        } dp[i] = -1 dp[i] dp i -1 1 n = in.nextInt() n in.nextInt() in.nextInt in for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            h[i] = in.nextInt();
        } {
            h[i] = in.nextInt();
        } h[i] = in.nextInt() h[i] h i in.nextInt() in.nextInt in System.out.println(solve(0)) System.out.println System.out System System.out solve(0) solve 0 String[] args args public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 2;
    public static int[] h = new int[100001];
    public static long[] dp = new long[100001];
    public final static long oo = 10000000000l;

    public static long solve(int idx) {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    }

} public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 2;
    public static int[] h = new int[100001];
    public static long[] dp = new long[100001];
    public final static long oo = 10000000000l;

    public static long solve(int idx) {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    }

} Main

import java.util.*;

public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 2;
    public static int[] h = new int[100001];
    public static long[] dp = new long[100001];
    public final static long oo = 10000000000l;

    public static long solve(int idx) {
        if (idx == n - 1) {
            return 0;
        } else {
            if (dp[idx] == -1) {
                long c1 = solve(idx + 1) + Math.abs(h[idx] - h[idx + 1]);
                long c2 = oo;
                if (n - idx > 2) {
                    c2 = solve(idx + 2) + Math.abs(h[idx] - h[idx + 2]);
                }
                return dp[idx] = Math.min(c1, c2);
            } else {
                return dp[idx];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            dp[i] = -1;
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }
        System.out.println(solve(0));
    }

}
