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