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