import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	}
	
	public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	}
	
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	}
	
	public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	}
	
} Main public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	} main {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int arraySize = scan.nextInt(); arraySize scan.nextInt() scan.nextInt scan int inputArray[] = new int[arraySize+1]; inputArray new int[arraySize+1] arraySize+1 arraySize 1 for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		} int i =1; int i =1; i 1 i<=arraySize i arraySize i++ i++ i {
			inputArray[i] = scan.nextInt();
		} {
			inputArray[i] = scan.nextInt();
		} inputArray[i] = scan.nextInt() inputArray[i] inputArray i scan.nextInt() scan.nextInt scan System.out.println(findMinCost(inputArray)) System.out.println System.out System System.out findMinCost(inputArray) findMinCost inputArray String args[] args public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	} findMinCost {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	} int size = inputArray.length; size inputArray.length inputArray inputArray.length int dp[] = new int[size]; dp new int[size] size dp[1] = 0 dp[1] dp 1 0 for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		} int i = 2; int i = 2; i 2 i<size i size i++ i++ i {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		} {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		} int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1]; option1 Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1] Math.abs(inputArray[i]-inputArray[i-1]) Math.abs Math inputArray[i]-inputArray[i-1] inputArray[i] inputArray i inputArray[i-1] inputArray i-1 i 1 dp[i-1] dp i-1 i 1 int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2]; option2 (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2] (i==2) i 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2] Math.abs(inputArray[i]-inputArray[i-2]) Math.abs Math inputArray[i]-inputArray[i-2] inputArray[i] inputArray i inputArray[i-2] inputArray i-2 i 2 dp[i-2] dp i-2 i 2 dp[i] = Math.min(option1,option2) dp[i] dp i Math.min(option1,option2) Math.min Math option1 option2 return dp[size-1]; dp[size-1] dp size-1 size 1 int[]inputArray inputArray public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	}
	
	public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	}
	
} public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	}
	
	public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	}
	
} Main
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	}
	
	public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	}
	
}