import java.util.*;
 
public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    }
  
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    }
  
} Main public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    } main {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int t = sc.nextInt(); t sc.nextInt() sc.nextInt sc int[] arr = new int[t]; arr new int[t] t for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      } int i =0; int i =0; i 0 i<t i t i++ i++ i {
        arr[i]= sc.nextInt();
      } {
        arr[i]= sc.nextInt();
      } arr[i]= sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int[] dp = new int[t]; dp new int[t] t dp[0] = 0 dp[0] dp 0 0 dp[1]= Math.abs(arr[0]-arr[1]) dp[1] dp 1 Math.abs(arr[0]-arr[1]) Math.abs Math arr[0]-arr[1] arr[0] arr 0 arr[1] arr 1 for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      } int i =2; int i =2; i 2 i<t i t i++ i++ i {
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      } {
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      } int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]); f dp[i-1]+ Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 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 int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]); s dp[i-2]+ Math.abs(arr[i]-arr[i-2]) dp[i-2] dp i-2 i 2 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(f,s) dp[i] dp i Math.min(f,s) Math.min Math f s System.out.println(dp[dp.length-1]) System.out.println System.out System System.out dp[dp.length-1] dp dp.length-1 dp.length dp dp.length 1 String[] args args public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    }
  
} public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    }
  
} Main
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int t = sc.nextInt();
      int[] arr = new int[t];
      for(int i =0;i<t;i++){
        arr[i]= sc.nextInt();
      }
      int[] dp = new int[t];
      dp[0] = 0;
      dp[1]= Math.abs(arr[0]-arr[1]);
      for(int i =2;i<t;i++){
        int f = dp[i-1]+ Math.abs(arr[i]-arr[i-1]);
        int s = dp[i-2]+ Math.abs(arr[i]-arr[i-2]);
        dp[i]= Math.min(f,s);
      }
      System.out.println(dp[dp.length-1]);
    }
  
}
