// A java program to find minimum possible 
// time by the car chassis to complete 
import java.io.*; 
import java.util.*;

class Main
{ 
	
	
	
	// Driver code 
	public static void main (String[] args) throws IOException
	{ 
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        
	        String[] ip;
	       
	            
	            int n = Integer.parseInt(br.readLine());
	            
	            ip = br.readLine().trim().split("\\s+");
	            int[] arr = new int[n];
	            for(int i=0;i<n;i++){
	                arr[i] = Integer.parseInt(ip[i]);
	            }
	            fun(arr,n);


	
	} 

	static void fun(int[] arr,int n){

		int[] dp = new int[n];

		dp[0]=0;
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		}

		
			System.out.print(dp[n-1]);
	}

	
} 
 import java.io.*; io.* java import java.util.*; util.* java class Main
{ 
	
	
	
	// Driver code 
	public static void main (String[] args) throws IOException
	{ 
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        
	        String[] ip;
	       
	            
	            int n = Integer.parseInt(br.readLine());
	            
	            ip = br.readLine().trim().split("\\s+");
	            int[] arr = new int[n];
	            for(int i=0;i<n;i++){
	                arr[i] = Integer.parseInt(ip[i]);
	            }
	            fun(arr,n);


	
	} 

	static void fun(int[] arr,int n){

		int[] dp = new int[n];

		dp[0]=0;
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		}

		
			System.out.print(dp[n-1]);
	}

	
} Main // Driver code 
	public static void main (String[] args) throws IOException
	{ 
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        
	        String[] ip;
	       
	            
	            int n = Integer.parseInt(br.readLine());
	            
	            ip = br.readLine().trim().split("\\s+");
	            int[] arr = new int[n];
	            for(int i=0;i<n;i++){
	                arr[i] = Integer.parseInt(ip[i]);
	            }
	            fun(arr,n);


	
	} main { 
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        
	        String[] ip;
	       
	            
	            int n = Integer.parseInt(br.readLine());
	            
	            ip = br.readLine().trim().split("\\s+");
	            int[] arr = new int[n];
	            for(int i=0;i<n;i++){
	                arr[i] = Integer.parseInt(ip[i]);
	            }
	            fun(arr,n);


	
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] ip; ip int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br ip = br.readLine().trim().split("\\s+") ip br.readLine().trim().split("\\s+") br.readLine().trim().split br.readLine().trim() br.readLine().trim br.readLine() br.readLine br "\\s+" int[] arr = new int[n]; arr new int[n] n for(int i=0;i<n;i++){
	                arr[i] = Integer.parseInt(ip[i]);
	            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
	                arr[i] = Integer.parseInt(ip[i]);
	            } {
	                arr[i] = Integer.parseInt(ip[i]);
	            } arr[i] = Integer.parseInt(ip[i]) arr[i] arr i Integer.parseInt(ip[i]) Integer.parseInt Integer ip[i] ip i fun(arr,n) fun arr n String[] args args static void fun(int[] arr,int n){

		int[] dp = new int[n];

		dp[0]=0;
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		}

		
			System.out.print(dp[n-1]);
	} fun {

		int[] dp = new int[n];

		dp[0]=0;
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		}

		
			System.out.print(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(arr[1]-arr[0]) dp[1] dp 1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2;i<n;i++){
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		} {
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		} int gap1=0 gap1 0 gap2=0; gap2 0 if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			} i-1>=0 i-1 i 1 0 {
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			} gap1 = Math.abs(arr[i]-arr[i-1]) gap1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 gap1 = gap1 + dp[i-1] gap1 gap1 + dp[i-1] gap1 dp[i-1] dp i-1 i 1 if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			} i-2>=0 i-2 i 2 0 {
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			} gap2 = Math.abs(arr[i]-arr[i-2]) gap2 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 gap2 = gap2 + dp[i-2] gap2 gap2 + dp[i-2] gap2 dp[i-2] dp i-2 i 2 dp[i] = Math.min(gap1,gap2) dp[i] dp i Math.min(gap1,gap2) Math.min Math gap1 gap2 System.out.print(dp[n-1]) System.out.print System.out System System.out dp[n-1] dp n-1 n 1 int[] arr arr int n n
// A java program to find minimum possible 
// time by the car chassis to complete 
import java.io.*; 
import java.util.*;

class Main
{ 
	
	
	
	// Driver code 
	public static void main (String[] args) throws IOException
	{ 
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        
	        String[] ip;
	       
	            
	            int n = Integer.parseInt(br.readLine());
	            
	            ip = br.readLine().trim().split("\\s+");
	            int[] arr = new int[n];
	            for(int i=0;i<n;i++){
	                arr[i] = Integer.parseInt(ip[i]);
	            }
	            fun(arr,n);


	
	} 

	static void fun(int[] arr,int n){

		int[] dp = new int[n];

		dp[0]=0;
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			

			int gap1=0,gap2=0;

			if(i-1>=0){
				gap1 = Math.abs(arr[i]-arr[i-1]);
				gap1 = gap1 + dp[i-1];
			}
			

			if(i-2>=0){
				gap2 = Math.abs(arr[i]-arr[i-2]);
				gap2 = gap2 + dp[i-2];
			}
			

			dp[i] = Math.min(gap1,gap2);

		


		}

		
			System.out.print(dp[n-1]);
	}

	
} 

