import java.io.*;
import java.util.*;
public class Main{
	static int n;
	static int[] height;
	public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
	static int n;
	static int[] height;
	public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    }
} Main static int n; n static int[] height; height public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	} solve {
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	} int[] dp=new int[n]; dp new int[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(height[0]-height[1]) dp[1] dp 1 Math.abs(height[0]-height[1]) Math.abs Math height[0]-height[1] height[0] height 0 height[1] height 1 for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		} {
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		} dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2])) dp[i] dp i Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2])) Math.min Math dp[i-1]+Math.abs(height[i]-height[i-1]) dp[i-1] dp i-1 i 1 Math.abs(height[i]-height[i-1]) Math.abs Math height[i]-height[i-1] height[i] height i height[i-1] height i-1 i 1 dp[i-2]+Math.abs(height[i]-height[i-2]) dp[i-2] dp i-2 i 2 Math.abs(height[i]-height[i-2]) Math.abs Math height[i]-height[i-2] height[i] height i height[i-2] height i-2 i 2 return dp[n-1]; dp[n-1] dp n-1 n 1 public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    } main {
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    } BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); br new BufferedReader( 
                              new InputStreamReader(System.in)) n=Integer.parseInt(br.readLine()) n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br height=new int[n] height new int[n] n String[] str=br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {			
		   height[i]=Integer.parseInt(str[i]);		 
		} {			
		   height[i]=Integer.parseInt(str[i]);		 
		} height[i]=Integer.parseInt(str[i]) height[i] height i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(solve()) System.out.println System.out System System.out solve() solve String[] args args public class Main{
	static int n;
	static int[] height;
	public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    }
} public class Main{
	static int n;
	static int[] height;
	public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    }
} Main
import java.io.*;
import java.util.*;
public class Main{
	static int n;
	static int[] height;
	public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    }
}