import java.util.*;

public class Main{ 

   public static void main(String args[]) {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    }

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

   public static void main(String args[]) {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    }

} Main public static void main(String args[]) {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    } main {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    } Scanner s=new Scanner(System.in); s new Scanner(System.in) int n=s.nextInt(); n s.nextInt() s.nextInt s long h[]=new long[n]; h new long[n] n for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	} int i=0; int i=0; i 0 i<n i n i++ i++ i {
    		h[i]=s.nextLong();
    	} {
    		h[i]=s.nextLong();
    	} h[i]=s.nextLong() h[i] h i s.nextLong() s.nextLong s long dp[]=new long[n]; dp new long[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(h[1]-h[0]) dp[1] dp 1 Math.abs(h[1]-h[0]) Math.abs Math h[1]-h[0] h[1] h 1 h[0] h 0 for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	} int i=2; int i=2; i 2 i<n i n i++ i++ i {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	} {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	} long op1=dp[i-1] + Math.abs(h[i]-h[i-1]); op1 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 long op2=dp[i-2] + Math.abs(h[i]-h[i-2]); op2 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 dp[i]=Math.min(op1, op2) dp[i] dp i Math.min(op1, op2) Math.min Math op1 op2 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 s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    }

} public class Main{ 

   public static void main(String args[]) {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    }

} Main
import java.util.*;

public class Main{ 

   public static void main(String args[]) {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	long h[]=new long[n];
    	for(int i=0;i<n;i++) {
    		h[i]=s.nextLong();
    	}
    	long dp[]=new long[n];
    	dp[0]=0;
    	dp[1]=Math.abs(h[1]-h[0]);
    	
    	for(int i=2;i<n;i++) {
    		long op1=dp[i-1] + Math.abs(h[i]-h[i-1]);
    		long op2=dp[i-2] + Math.abs(h[i]-h[i-2]);
    		dp[i]=Math.min(op1, op2);
    	}
    	System.out.println(dp[n-1]);
    	
    }

}