import java.io.*;
class Main {

  public static void main(String[] args) {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    }
  
  }

} import java.io.*; io.* java class Main {

  public static void main(String[] args) {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    }
  
  }

} Main public static void main(String[] args) {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    }
  
  } main {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    }
  
  } try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    } catch(Exception ex) {
    
    } Exception ex {
    
    } {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String strLine = br.readLine(); strLine br.readLine() br.readLine br String costsLine = br.readLine(); costsLine br.readLine() br.readLine br int n = Integer.parseInt(strLine); n Integer.parseInt(strLine) Integer.parseInt Integer strLine String[] costs = costsLine.split(" "); costs costsLine.split(" ") costsLine.split costsLine " " int[] dp = new int[n]; dp new int[n] n dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0])) dp[1] dp 1 Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0])) Math.abs Math Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]) Integer.parseInt(costs[1]) Integer.parseInt Integer costs[1] costs 1 Integer.parseInt(costs[0]) Integer.parseInt Integer costs[0] costs 0 for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1]))) dp[i] dp i Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1]))) Math.min Math dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])) dp[i-2] dp i-2 i 2 Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])) Math.abs Math Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2]) Integer.parseInt(costs[i]) Integer.parseInt Integer costs[i] costs i Integer.parseInt(costs[i-2]) Integer.parseInt Integer costs[i-2] costs i-2 i 2 dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])) dp[i-1] dp i-1 i 1 Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])) Math.abs Math Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1]) Integer.parseInt(costs[i]) Integer.parseInt Integer costs[i] costs i Integer.parseInt(costs[i-1]) Integer.parseInt Integer costs[i-1] costs i-1 i 1 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
import java.io.*;
class Main {

  public static void main(String[] args) {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    }
  
  }

}