import java.util.*;
import java.lang.Math;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(dp[n-1]);
	}
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(dp[n-1]);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(dp[n-1]);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(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 int[] dp = new int[n]; dp 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 dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(h[0]-h[1]) dp[1] dp 1 Math.abs(h[0]-h[1]) Math.abs Math h[0]-h[1] h[0] h 0 h[1] h 1 for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		} {
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		} if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]); dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]) dp[i-1]+Math.abs(h[i-1]-h[i]) dp[i-1] dp i-1 i 1 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-2]+Math.abs(h[i-2]-h[i]) dp[i-2] dp i-2 i 2 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]=dp[i-2]+Math.abs(h[i-2]-h[i]) dp[i] dp i dp[i-2]+Math.abs(h[i-2]-h[i]) dp[i-2] dp i-2 i 2 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]=dp[i-1]+Math.abs(h[i-1]-h[i]) dp[i] dp i dp[i-1]+Math.abs(h[i-1]-h[i]) dp[i-1] dp i-1 i 1 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 System.out.print(dp[n-1]) System.out.print 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 sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(dp[n-1]);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(dp[n-1]);
	}
} Main
import java.util.*;
import java.lang.Math;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i=0;i<n;i++){
			h[i] =sc.nextInt();
		}
		
		dp[0]=0;
		dp[1]=Math.abs(h[0]-h[1]);
		for(int i=2;i<n;i++){
			if(dp[i-1]+Math.abs(h[i-1]-h[i]) > dp[i-2]+Math.abs(h[i-2]-h[i]))
			dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
			else
			dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
		}
		
		System.out.print(dp[n-1]);
	}
}