import java.util.Scanner;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt(),i, h[] = new int[N];
		for(i=0;i<N;i++)h[i]=sc.nextInt();
		int dp[]=new int[N+1];
		dp[0]=0;
		dp[1]=Math.abs(h[1]-h[0]);
		for(i=2;i<N;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]), dp[i-2]+Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[N-1]);
	}
} import java.util.Scanner; Scanner java.util class Main {

	static Scanner sc = new Scanner(System.in);

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

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt(),i, h[] = new int[N];
		for(i=0;i<N;i++)h[i]=sc.nextInt();
		int dp[]=new int[N+1];
		dp[0]=0;
		dp[1]=Math.abs(h[1]-h[0]);
		for(i=2;i<N;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]), dp[i-2]+Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[N-1]);
	}
}