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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	} main {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] dp = new int[n]; dp new int[n] n Arrays.fill(dp, Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE int []h = new int[n]; h new int[n] n for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			h[i] = stdIn.nextInt();
		} {
			h[i] = stdIn.nextInt();
		} h[i] = stdIn.nextInt() h[i] h i stdIn.nextInt() stdIn.nextInt stdIn dp[0] = 0 dp[0] dp 0 0 for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		} {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		} if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			} i == n-2 i n-2 n 2 {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			} dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]) dp[i+1] dp i+1 i 1 Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]) Math.min Math dp[i] + Math.abs(h[i+1]-h[i]) dp[i] dp i Math.abs(h[i+1]-h[i]) Math.abs Math h[i+1]-h[i] h[i+1] h i+1 i 1 h[i] h i dp[i+1] dp i+1 i 1 break; dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]) dp[i+1] dp i+1 i 1 Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]) Math.min Math dp[i]+Math.abs(h[i+1]-h[i]) dp[i] dp i Math.abs(h[i+1]-h[i]) Math.abs Math h[i+1]-h[i] h[i+1] h i+1 i 1 h[i] h i dp[i+1] dp i+1 i 1 dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]) dp[i+2] dp i+2 i 2 Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]) Math.min Math dp[i]+Math.abs(h[i+2]-h[i]) dp[i] dp i Math.abs(h[i+2]-h[i]) Math.abs Math h[i+2]-h[i] h[i+2] h i+2 i 2 h[i] h i dp[i+2] dp 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 public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		int []h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		dp[0] = 0;
		
		for(int i = 0; i < n; i++) {
			if(i == n-2) {
				dp[i+1] = Math.min(dp[i] + Math.abs(h[i+1]-h[i]), dp[i+1]);
				break;
			}
			
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i+1]-h[i]),dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+2]);
			
		}
		System.out.println(dp[n-1]);
		
	}

}
