import 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];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	} 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 int[] dp = new int[N]; dp new int[N] N dp[0] = 0 dp[0] dp 0 0 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 dp[1] = Math.abs(h[1] - h[0]) dp[1] dp 1 Math.abs(h[1] - h[0]) Math.abs Math h[1] - h[0] h[1] h 1 h[0] h 0 for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		} int i = 1; int i = 1; i 1 i < N - 1 i N - 1 N 1 i++ i++ i {
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		} {
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		} int jump = Math.abs(h[i + 1] - h[i]); jump 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 int highJump = Math.abs(h[i + 1] - h[i - 1]); highJump Math.abs(h[i + 1] - h[i - 1]) Math.abs Math h[i + 1] - h[i - 1] h[i + 1] h i + 1 i 1 h[i - 1] h i - 1 i 1 dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]) dp[i + 1] dp i + 1 i 1 Math.min(jump + dp[i],highJump + dp[i - 1]) Math.min Math jump + dp[i] jump dp[i] dp i highJump + dp[i - 1] highJump dp[i - 1] dp 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 sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-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];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	}
} Main
import 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];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	}
}