import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	}
	
	
	
	
	
	
	
	
	public static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	}
} 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[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	}
	
	
	
	
	
	
	
	
	public static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	} main {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] h = new int[n]; h new int[n] n for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			h[i] = sc.nextInt();
		} {
			h[i] = sc.nextInt();
		} h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc long[] dp = new long[100001]; dp new long[100001] 100001 for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			dp[i] = 9223372036854775807l;
		} {
			dp[i] = 9223372036854775807l;
		} dp[i] = 9223372036854775807l dp[i] dp i 9223372036854775807l dp[0] = 0 dp[0] dp 0 0 for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		} {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		} dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1])) dp[i] dp i chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1])) chmin dp[i] dp i dp[i - 1] + Math.abs(h[i] - h[i - 1]) dp[i - 1] dp i - 1 i 1 Math.abs(h[i] - h[i - 1]) Math.abs Math h[i] - h[i - 1] h[i] h i h[i - 1] h i - 1 i 1 if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2])); i>1 i 1 dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2])) dp[i] dp i chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2])) chmin dp[i] dp i dp[i - 2] + Math.abs(h[i] - h[i - 2]) dp[i - 2] dp i - 2 i 2 Math.abs(h[i] - h[i - 2]) Math.abs Math h[i] - h[i - 2] h[i] h i h[i - 2] h 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 static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	} chmin {
		if(a > b) {
			a = b;
		}
		return a;
	} if(a > b) {
			a = b;
		} a > b a b {
			a = b;
		} a = b a b return a; a long a a long b b public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	}
	
	
	
	
	
	
	
	
	public static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	}
	
	
	
	
	
	
	
	
	public static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	}
} 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[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	}
	
	
	
	
	
	
	
	
	public static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	}
}