import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    }
} Main public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    } main {
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = Integer.parseInt(in.nextLine().trim()); n Integer.parseInt(in.nextLine().trim()) Integer.parseInt Integer in.nextLine().trim() in.nextLine().trim in.nextLine() in.nextLine in int[] h = new int[n]; h new int[n] n int count = 0; count 0 for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        } String a in.nextLine().trim().split("\\s") in.nextLine().trim().split in.nextLine().trim() in.nextLine().trim in.nextLine() in.nextLine in "\\s" {
            h[count++] = Integer.parseInt(a);
        } {
            h[count++] = Integer.parseInt(a);
        } h[count++] = Integer.parseInt(a) h[count++] h count++ count Integer.parseInt(a) Integer.parseInt Integer a int[] dp = new int[n]; dp new int[n] n for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        } {
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        } int cost = Integer.MAX_VALUE; cost Integer.MAX_VALUE Integer Integer.MAX_VALUE if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            } i-2 > -1 i-2 i 2 -1 1 {
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            } cost = dp[i-2] + Math.abs(h[i]-h[i-2]) cost dp[i-2] + Math.abs(h[i]-h[i-2]) dp[i-2] dp i-2 i 2 Math.abs(h[i]-h[i-2]) Math.abs Math h[i]-h[i-2] h[i] h i h[i-2] h i-2 i 2 dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1])) dp[i] dp i Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1])) Math.min Math cost dp[i-1] + Math.abs(h[i]-h[i-1]) dp[i-1] dp i-1 i 1 Math.abs(h[i]-h[i-1]) Math.abs Math h[i]-h[i-1] h[i] h i h[i-1] h i-1 i 1 System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 String[] args args public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    }
} public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            int cost = Integer.MAX_VALUE;
            if(i-2 > -1){
                cost = dp[i-2] + Math.abs(h[i]-h[i-2]);
            }
            dp[i] = Math.min(cost,dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
    }
}