import java.util.*;
public class Main{

	public static void main(String[]args){
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	}
	public static int jump(int i,int n,int []h,int[] dp){
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

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

	public static void main(String[]args){
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	}
	public static int jump(int i,int n,int []h,int[] dp){
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

	}
} Main public static void main(String[]args){
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	} main {
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	} Scanner scan  = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] h = new int[n+1]; h new int[n+1] n+1 n 1 for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
			h[i] = scan.nextInt();
		} {
			h[i] = scan.nextInt();
		} h[i] = scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan int[] dp = new int[n+1]; dp new int[n+1] n+1 n 1 Arrays.fill(dp,-1) Arrays.fill Arrays dp -1 1 jump(1,n,h,dp) jump 1 n h dp System.out.println(dp[1]) System.out.println System.out System System.out dp[1] dp 1 String[]args args public static int jump(int i,int n,int []h,int[] dp){
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

	} jump {
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

	} if(i==n) return 0; i==n i n return 0; 0 if(i>n) return (int)1e5; i>n i n return (int)1e5; (int)1e5 if(dp[i]!=-1)return dp[i]; dp[i]!=-1 dp[i] dp i -1 1 return dp[i]; dp[i] dp i int k = 100005; k 100005 int g = 100005; g 100005 if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		} i+1<=n i+1 i 1 n {
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		} k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp) k Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp) 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 jump(i+1,n,h,dp) jump i+1 i 1 n h dp if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		} i+2<=n i+2 i 2 n {
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		} g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp) g Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp) 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 jump(i+2,n,h,dp) jump i+2 i 2 n h dp dp[i]=Math.min(k,g) dp[i] dp i Math.min(k,g) Math.min Math k g return dp[i]; dp[i] dp i int i i int n n int []h h int[] dp dp public class Main{

	public static void main(String[]args){
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	}
	public static int jump(int i,int n,int []h,int[] dp){
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

	}
} public class Main{

	public static void main(String[]args){
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	}
	public static int jump(int i,int n,int []h,int[] dp){
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

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

	public static void main(String[]args){
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n+1];
		for(int i=1;i<=n;i++){
			h[i] = scan.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp,-1);
		jump(1,n,h,dp);
		System.out.println(dp[1]);
	}
	public static int jump(int i,int n,int []h,int[] dp){
//		System.out.println("start "+i);
		if(i==n) return 0;
		if(i>n) return (int)1e5;
		if(dp[i]!=-1)return dp[i];
		int k = 100005;
		int g = 100005;
		if(i+1<=n){
			k = Math.abs(h[i+1]-h[i])+jump(i+1,n,h,dp);
			//System.out.println("k= "+k+" "+i+"->"+(i+1));
		}
		if(i+2<=n){
			g = Math.abs(h[i+2]-h[i])+jump(i+2,n,h,dp);
			//System.out.println("g= "+g+" "+i+"->"+(i+2));
		}
		dp[i]=Math.min(k,g);
		return dp[i];

	}
}
