import java.util.*;
import java.io.*;

public class Main {
  
   public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  }
         
}
    
     import java.util.*; util.* java import java.io.*; io.* java public class Main {
  
   public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  }
         
} Main public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   } main {
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   } Main sol = new Main(); sol new Main() long answer = sol.solve(); answer sol.solve() sol.solve sol System.out.println(answer) System.out.println System.out System System.out answer String []abc abc private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  } solve {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long [] array = new long [N]; array new long [N] N for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        array[i] = sc.nextLong();
     } {
        array[i] = sc.nextLong();
     } array[i] = sc.nextLong() array[i] array i sc.nextLong() sc.nextLong sc long dp[] = new long[N+1]; dp new long[N+1] N+1 N 1 for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     } int i=0; int i=0; i 0 i<N i N i++ i++ i {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     } {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     } if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       } i==0 i 0 dp[i]=0 dp[i] dp i 0 if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       } i==1 i 1 dp[i] = Math.abs(array[i]-array[i-1]) dp[i] dp i Math.abs(array[i]-array[i-1]) Math.abs Math array[i]-array[i-1] array[i] array i array[i-1] array i-1 i 1 {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       } dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2])) dp[i] dp i Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2])) Math.min Math dp[i-1]+ Math.abs(array[i]-array[i-1]) dp[i-1] dp i-1 i 1 Math.abs(array[i]-array[i-1]) Math.abs Math array[i]-array[i-1] array[i] array i array[i-1] array i-1 i 1 dp[i-2]+Math.abs(array[i]-array[i-2]) dp[i-2] dp i-2 i 2 Math.abs(array[i]-array[i-2]) Math.abs Math array[i]-array[i-2] array[i] array i array[i-2] array i-2 i 2 return dp[N-1]; dp[N-1] dp N-1 N 1 public class Main {
  
   public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  }
         
} public class Main {
  
   public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  }
         
} Main
import java.util.*;
import java.io.*;

public class Main {
  
   public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  }
         
}
    
    
