
import java.util.*;

public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    }
    public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    }

} import java.util.*; util.* java public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    }
    public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    }

} Main public static Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    } main {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    } int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int stones[] = new int[n+1]; stones new int[n+1] n+1 n 1 int dp[] = new int[n+1]; dp new int[n+1] n+1 n 1 for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        } int i = 1 ; int i = 1 ; i 1 i <= n i n i++ i++ i {
            stones[i] = scanner.nextInt();
        } {
            stones[i] = scanner.nextInt();
        } stones[i] = scanner.nextInt() stones[i] stones i scanner.nextInt() scanner.nextInt scanner System.out.println(solve(stones,dp , n)) System.out.println System.out System System.out solve(stones,dp , n) solve stones dp n String[] args args public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    } solve {
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    } if(n <=1){
            return 0;
        } n <=1 n 1 {
            return 0;
        } return 0; 0 for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        } int j = 2 ; int j = 2 ; j 2 j<= n j n j++ j++ j {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        } {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        } int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1]; opt1 Math.abs(stones[j] - stones[j-1]) + dp[j-1] Math.abs(stones[j] - stones[j-1]) Math.abs Math stones[j] - stones[j-1] stones[j] stones j stones[j-1] stones j-1 j 1 dp[j-1] dp j-1 j 1 int opt2= 0; opt2 0 if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            } j == 2 j 2 {
                opt2 = Integer.MAX_VALUE;
            } opt2 = Integer.MAX_VALUE opt2 Integer.MAX_VALUE Integer Integer.MAX_VALUE {
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            } opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2] opt2 Math.abs(stones[j] - stones[j-2]) + dp[j - 2] Math.abs(stones[j] - stones[j-2]) Math.abs Math stones[j] - stones[j-2] stones[j] stones j stones[j-2] stones j-2 j 2 dp[j - 2] dp j - 2 j 2 dp[j] = Math.min(opt1, opt2) dp[j] dp j Math.min(opt1, opt2) Math.min Math opt1 opt2 return dp[n]; dp[n] dp n int[] stones stones int[] dp dp int n n public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    }
    public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    }

} public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    }
    public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    }

} Main

import java.util.*;

public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    }
    public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    }

}
