import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] stepInfo = new int[n]; stepInfo new int[n] n for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		} int i =0; int i =0; i 0 i < n i n i++ i++ i {
			stepInfo[i] = sc.nextInt();
		} {
			stepInfo[i] = sc.nextInt();
		} stepInfo[i] = sc.nextInt() stepInfo[i] stepInfo i sc.nextInt() sc.nextInt sc int[] minimumCostInfo = new int[n]; minimumCostInfo new int[n] n minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]) minimumCostInfo[1] minimumCostInfo 1 Math.abs(stepInfo[1]-stepInfo[0]) Math.abs Math stepInfo[1]-stepInfo[0] stepInfo[1] stepInfo 1 stepInfo[0] stepInfo 0 for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		} int i =2; int i =2; i 2 i < n i n i++ i++ i {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		} {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		} int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]); costBeforeOne minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]) minimumCostInfo[i-1] minimumCostInfo i-1 i 1 Math.abs(stepInfo[i]-stepInfo[i-1]) Math.abs Math stepInfo[i]-stepInfo[i-1] stepInfo[i] stepInfo i stepInfo[i-1] stepInfo i-1 i 1 int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]); costBeforeTwo minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]) minimumCostInfo[i-2] minimumCostInfo i-2 i 2 Math.abs(stepInfo[i]-stepInfo[i-2]) Math.abs Math stepInfo[i]-stepInfo[i-2] stepInfo[i] stepInfo i stepInfo[i-2] stepInfo i-2 i 2 if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			} costBeforeOne> costBeforeTwo costBeforeOne costBeforeTwo {
				minimumCostInfo[i] = costBeforeTwo;
			} minimumCostInfo[i] = costBeforeTwo minimumCostInfo[i] minimumCostInfo i costBeforeTwo {
				minimumCostInfo[i] = costBeforeOne;
			} minimumCostInfo[i] = costBeforeOne minimumCostInfo[i] minimumCostInfo i costBeforeOne System.out.println(minimumCostInfo[n-1]) System.out.println System.out System System.out minimumCostInfo[n-1] minimumCostInfo 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[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	}
}