import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
} Main public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    } main {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter w = new PrintWriter(System.out); w new PrintWriter(System.out) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int height[] = new int[n]; height new int[n] n for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
          height[i] = sc.nextInt();
      } {
          height[i] = sc.nextInt();
      } height[i] = sc.nextInt() height[i] height i sc.nextInt() sc.nextInt sc int dp[] = new int[n]; dp new int[n] n dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(height[1] - height[0]) dp[1] dp 1 Math.abs(height[1] - height[0]) Math.abs Math height[1] - height[0] height[1] height 1 height[0] height 0 for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      } {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      } dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2])) dp[i] dp i Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2])) Math.min Math dp[i-1] + Math.abs(height[i] - height[i-1]) dp[i-1] dp i-1 i 1 Math.abs(height[i] - height[i-1]) Math.abs Math height[i] - height[i-1] height[i] height i height[i-1] height i-1 i 1 dp[i-2] + Math.abs(height[i] - height[i-2]) dp[i-2] dp i-2 i 2 Math.abs(height[i] - height[i-2]) Math.abs Math height[i] - height[i-2] height[i] height i height[i-2] height i-2 i 2 w.println(dp[n-1]) w.println w dp[n-1] dp n-1 n 1 w.close() w.close w String args[] args public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
} public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
} Main
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
}