import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	}
} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	} main {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] arr = new int[n]; arr new int[n] n int[] dp = new int[n]; dp new int[n] n for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i arr[i] = sc.nextInt(); arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc Arrays.fill(dp, 0) Arrays.fill Arrays dp 0 if(n == 1) {
			System.out.println(arr[0]);
			return;
		} n == 1 n 1 {
			System.out.println(arr[0]);
			return;
		} System.out.println(arr[0]) System.out.println System.out System System.out arr[0] arr 0 return; dp[1] = Math.abs(arr[1] - arr[0]) dp[1] dp 1 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 < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		} int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		} {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		} int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]); a dp[i-1] + Math.abs(arr[i] - arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i] - arr[i-1]) Math.abs Math arr[i] - arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]); b dp[i-2] + Math.abs(arr[i] - arr[i-2]) dp[i-2] dp i-2 i 2 Math.abs(arr[i] - arr[i-2]) Math.abs Math arr[i] - arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 dp[i] = Math.min(a, b) dp[i] dp i Math.min(a, b) Math.min Math a b System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 return; String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	}
} Main
import java.util.*;

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