    import java.util.*;
    public class Main{
     	public static void main(String args[]){
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     }  
    } import java.util.*; util.* java public class Main{
     	public static void main(String args[]){
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     }  
    } Main public static void main(String args[]){
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     } main {
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int [] h = new int[n]; h new int[n] n for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          } int i =0; int i =0; i 0 i<n i n i++ i++ i {
          	h[i]=s.nextInt();
          } {
          	h[i]=s.nextInt();
          } h[i]=s.nextInt() h[i] h i s.nextInt() s.nextInt s int [] dp = new int [n+1]; dp new int [n+1] n+1 n 1 Arrays.fill(dp,Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[1]=0 dp[1] dp 1 0 for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        } int i =2; int i =2; i 2 i<=n i n i++ i++ i {
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        } {
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        } dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]) dp[i] dp i Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]) Math.min Math dp[i-1]+Math.abs(h[i-1]-h[i-2]) dp[i-1] dp i-1 i 1 Math.abs(h[i-1]-h[i-2]) Math.abs Math h[i-1]-h[i-2] h[i-1] h i-1 i 1 h[i-2] h i-2 i 2 dp[i] dp i if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]); i>=3 i 3 dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]) dp[i] dp i Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]) Math.min Math dp[i-2]+Math.abs(h[i-1]-h[i-3]) dp[i-2] dp i-2 i 2 Math.abs(h[i-1]-h[i-3]) Math.abs Math h[i-1]-h[i-3] h[i-1] h i-1 i 1 h[i-3] h i-3 i 3 dp[i] dp i System.out.println( dp[n]) System.out.println System.out System System.out dp[n] dp n String args[] args public class Main{
     	public static void main(String args[]){
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     }  
    } public class Main{
     	public static void main(String args[]){
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     }  
    } Main
    import java.util.*;
    public class Main{
     	public static void main(String args[]){
        	Scanner s = new Scanner(System.in);
         	int n = s.nextInt();
          	int [] h = new int[n];
          for(int i =0;i<n;i++){
          	h[i]=s.nextInt();
          }
          int [] dp = new int [n+1];
          
          Arrays.fill(dp,Integer.MAX_VALUE);
          dp[1]=0;
                  
          for(int i =2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i-2]),dp[i]);
              if(i>=3)
            dp[i]=Math.min(dp[i-2]+Math.abs(h[i-1]-h[i-3]),dp[i]);               
        }
                   System.out.println( dp[n]);
     
     }  
    }