import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    }

    static int solve(int[] h) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    }

    static int solve(int[] h) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] h = new int[N]; h new int[N] N for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < h.length i h.length h h.length ++i ++i i {
            h[i] = sc.nextInt();
        } {
            h[i] = sc.nextInt();
        } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc System.out.println(solve(h)) System.out.println System.out System System.out solve(h) solve h sc.close() sc.close sc String[] args args static int solve(int[] h) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    } solve {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    } int[] costs = new int[h.length]; costs new int[h.length] h.length h h.length Arrays.fill(costs, Integer.MAX_VALUE) Arrays.fill Arrays costs Integer.MAX_VALUE Integer Integer.MAX_VALUE costs[0] = 0 costs[0] costs 0 0 for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        } int i = 1; int i = 1; i 1 i < costs.length i costs.length costs costs.length ++i ++i i {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        } {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        } for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            } int j = 1; int j = 1; j 1 j <= 2 && j <= i j <= 2 j 2 j <= i j i ++j ++j j {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            } {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            } costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j])) costs[i] costs i Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j])) Math.min Math costs[i] costs i costs[i - j] + Math.abs(h[i] - h[i - j]) costs[i - j] costs i - j i j Math.abs(h[i] - h[i - j]) Math.abs Math h[i] - h[i - j] h[i] h i h[i - j] h i - j i j return costs[costs.length - 1]; costs[costs.length - 1] costs costs.length - 1 costs.length costs costs.length 1 int[] h h public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    }

    static int solve(int[] h) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    }

    static int solve(int[] h) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h));

        sc.close();
    }

    static int solve(int[] h) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 1; i < costs.length; ++i) {
            for (int j = 1; j <= 2 && j <= i; ++j) {
                costs[i] = Math.min(costs[i], costs[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }

        return costs[costs.length - 1];
    }
}