import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long n;
    int[] h;
    long[] dp;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        dp();
        System.out.println(dp[(int)n-1]);
    }
    
    private void dp() {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long n;
    int[] h;
    long[] dp;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        dp();
        System.out.println(dp[(int)n-1]);
    }
    
    private void dp() {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    }
} Main // 変数一覧
    long n; n int[] h; h long[] dp; dp public static void main(String[] args) {
        Main main = new Main();
        main.run();
    } main {
        Main main = new Main();
        main.run();
    } Main main = new Main(); main new Main() main.run() main.run main String[] args args public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    } run {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) n = sc.nextLong() n sc.nextLong() sc.nextLong sc h = new int[(int)n] h new int[(int)n] (int)n for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            h[i] = sc.nextInt();
        } {
            h[i] = sc.nextInt();
        } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc sc.close() sc.close sc solve() solve private void solve() {
        dp();
        System.out.println(dp[(int)n-1]);
    } solve {
        dp();
        System.out.println(dp[(int)n-1]);
    } dp() dp System.out.println(dp[(int)n-1]) System.out.println System.out System System.out dp[(int)n-1] dp (int)n-1 (int)n 1 private void dp() {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    } dp {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    } dp = new long[(int)n] dp new long[(int)n] (int)n dp[0] = 0 dp[0] dp 0 0 for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        } {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        } if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            } i>1 i 1 {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i])) dp[i] dp i Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i])) Math.min Math 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 {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            } dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]) dp[i] dp i 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 public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long n;
    int[] h;
    long[] dp;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        dp();
        System.out.println(dp[(int)n-1]);
    }
    
    private void dp() {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    }
} public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long n;
    int[] h;
    long[] dp;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        dp();
        System.out.println(dp[(int)n-1]);
    }
    
    private void dp() {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long n;
    int[] h;
    long[] dp;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        h = new int[(int)n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        dp();
        System.out.println(dp[(int)n-1]);
    }
    
    private void dp() {
        dp = new long[(int)n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            if(i>1) {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            } else {
                dp[i] = dp[i-1] + Math.abs(h[i-1] - h[i]);
            }
        }
    }
}