import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	}
} import java.util.*; util.* java public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	} inputArray {
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	} int arr[] = new int[size]; arr new int[size] size for(int i=0;i<size;i++)arr[i]=sc.nextInt(); int i=0; int i=0; i 0 i<size i size i++ i++ i arr[i]=sc.nextInt(); arr[i]=sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc return arr; arr int size size public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	} main {
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	} int[] arr = inputArray(sc.nextInt()); arr inputArray(sc.nextInt()) inputArray sc.nextInt() sc.nextInt sc int[] dp = new int[arr.length]; dp new int[arr.length] arr.length arr arr.length dp[0]=0 dp[0] dp 0 0 dp[1]=(int)Math.abs(arr[1]-arr[0]) dp[1] dp 1 (int)Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		} int i=2; int i=2; i 2 i<dp.length i dp.length dp dp.length i++ i++ i {
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		} {
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		} dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i])) dp[i] dp i Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i])) Math.min Math dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]) dp[i-1] dp i-1 i 1 (int)Math.abs(arr[i-1]-arr[i]) Math.abs Math arr[i-1]-arr[i] arr[i-1] arr i-1 i 1 arr[i] arr i dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]) dp[i-2] dp i-2 i 2 (int)Math.abs(arr[i-2]-arr[i]) Math.abs Math arr[i-2]-arr[i] arr[i-2] arr i-2 i 2 arr[i] arr i System.out.println(dp[arr.length-1]) System.out.println System.out System System.out dp[arr.length-1] dp arr.length-1 arr.length arr arr.length 1 String[] args args public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	}
} public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	}
} Main
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	}
}