import java.util.*;
import java.lang.Math;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int numStones = scanner.nextInt();

    if (numStones < 2 || numStones > 100000) {
      System.out.println("0");
      return;
    }

    ArrayList<Integer> heights = new ArrayList<>();
    for (int i = 0; i < numStones; i++) {
      heights.add(i, scanner.nextInt());
    }
    int cost = calcCost(numStones, heights);
  
    System.out.println(cost);
  }

  public static int calcCost(int N, ArrayList<Integer> heights) {
    ArrayList<Integer> dp = new ArrayList<>();

    dp.add(0, 0);
    dp.add(1, Math.abs(heights.get(1)-heights.get(0)));
    
    if (N == 2) {
      return dp.get(1);
    }

    int cost;
    int firstJump;
    int secondJump;
    for (int i = 2; i < N; i++) {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    }
    return dp.get(N-1);
  }
} import java.util.*; util.* java import java.lang.Math; Math java.lang class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int numStones = scanner.nextInt();

    if (numStones < 2 || numStones > 100000) {
      System.out.println("0");
      return;
    }

    ArrayList<Integer> heights = new ArrayList<>();
    for (int i = 0; i < numStones; i++) {
      heights.add(i, scanner.nextInt());
    }
    int cost = calcCost(numStones, heights);
  
    System.out.println(cost);
  }

  public static int calcCost(int N, ArrayList<Integer> heights) {
    ArrayList<Integer> dp = new ArrayList<>();

    dp.add(0, 0);
    dp.add(1, Math.abs(heights.get(1)-heights.get(0)));
    
    if (N == 2) {
      return dp.get(1);
    }

    int cost;
    int firstJump;
    int secondJump;
    for (int i = 2; i < N; i++) {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    }
    return dp.get(N-1);
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int numStones = scanner.nextInt();

    if (numStones < 2 || numStones > 100000) {
      System.out.println("0");
      return;
    }

    ArrayList<Integer> heights = new ArrayList<>();
    for (int i = 0; i < numStones; i++) {
      heights.add(i, scanner.nextInt());
    }
    int cost = calcCost(numStones, heights);
  
    System.out.println(cost);
  } main {
    Scanner scanner = new Scanner(System.in);
    int numStones = scanner.nextInt();

    if (numStones < 2 || numStones > 100000) {
      System.out.println("0");
      return;
    }

    ArrayList<Integer> heights = new ArrayList<>();
    for (int i = 0; i < numStones; i++) {
      heights.add(i, scanner.nextInt());
    }
    int cost = calcCost(numStones, heights);
  
    System.out.println(cost);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int numStones = scanner.nextInt(); numStones scanner.nextInt() scanner.nextInt scanner if (numStones < 2 || numStones > 100000) {
      System.out.println("0");
      return;
    } numStones < 2 || numStones > 100000 numStones < 2 numStones 2 numStones > 100000 numStones 100000 {
      System.out.println("0");
      return;
    } System.out.println("0") System.out.println System.out System System.out "0" return; ArrayList<Integer> heights = new ArrayList<>(); heights new ArrayList<>() for (int i = 0; i < numStones; i++) {
      heights.add(i, scanner.nextInt());
    } int i = 0; int i = 0; i 0 i < numStones i numStones i++ i++ i {
      heights.add(i, scanner.nextInt());
    } {
      heights.add(i, scanner.nextInt());
    } heights.add(i, scanner.nextInt()) heights.add heights i scanner.nextInt() scanner.nextInt scanner int cost = calcCost(numStones, heights); cost calcCost(numStones, heights) calcCost numStones heights System.out.println(cost) System.out.println System.out System System.out cost String[] args args public static int calcCost(int N, ArrayList<Integer> heights) {
    ArrayList<Integer> dp = new ArrayList<>();

    dp.add(0, 0);
    dp.add(1, Math.abs(heights.get(1)-heights.get(0)));
    
    if (N == 2) {
      return dp.get(1);
    }

    int cost;
    int firstJump;
    int secondJump;
    for (int i = 2; i < N; i++) {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    }
    return dp.get(N-1);
  } calcCost {
    ArrayList<Integer> dp = new ArrayList<>();

    dp.add(0, 0);
    dp.add(1, Math.abs(heights.get(1)-heights.get(0)));
    
    if (N == 2) {
      return dp.get(1);
    }

    int cost;
    int firstJump;
    int secondJump;
    for (int i = 2; i < N; i++) {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    }
    return dp.get(N-1);
  } ArrayList<Integer> dp = new ArrayList<>(); dp new ArrayList<>() dp.add(0, 0) dp.add dp 0 0 dp.add(1, Math.abs(heights.get(1)-heights.get(0))) dp.add dp 1 Math.abs(heights.get(1)-heights.get(0)) Math.abs Math heights.get(1)-heights.get(0) heights.get(1) heights.get heights 1 heights.get(0) heights.get heights 0 if (N == 2) {
      return dp.get(1);
    } N == 2 N 2 {
      return dp.get(1);
    } return dp.get(1); dp.get(1) dp.get dp 1 int cost; cost int firstJump; firstJump int secondJump; secondJump for (int i = 2; i < N; i++) {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    } int i = 2; int i = 2; i 2 i < N i N i++ i++ i {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    } {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    } firstJump = Math.abs(heights.get(i)-heights.get(i-1)) firstJump Math.abs(heights.get(i)-heights.get(i-1)) Math.abs Math heights.get(i)-heights.get(i-1) heights.get(i) heights.get heights i heights.get(i-1) heights.get heights i-1 i 1 secondJump = Math.abs(heights.get(i)-heights.get(i-2)) secondJump Math.abs(heights.get(i)-heights.get(i-2)) Math.abs Math heights.get(i)-heights.get(i-2) heights.get(i) heights.get heights i heights.get(i-2) heights.get heights i-2 i 2 cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2)) cost Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2)) Math.min Math firstJump + dp.get(i-1) firstJump dp.get(i-1) dp.get dp i-1 i 1 secondJump + dp.get(i-2) secondJump dp.get(i-2) dp.get dp i-2 i 2 dp.add(i, cost) dp.add dp i cost return dp.get(N-1); dp.get(N-1) dp.get dp N-1 N 1 int N N ArrayList<Integer> heights heights
import java.util.*;
import java.lang.Math;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int numStones = scanner.nextInt();

    if (numStones < 2 || numStones > 100000) {
      System.out.println("0");
      return;
    }

    ArrayList<Integer> heights = new ArrayList<>();
    for (int i = 0; i < numStones; i++) {
      heights.add(i, scanner.nextInt());
    }
    int cost = calcCost(numStones, heights);
  
    System.out.println(cost);
  }

  public static int calcCost(int N, ArrayList<Integer> heights) {
    ArrayList<Integer> dp = new ArrayList<>();

    dp.add(0, 0);
    dp.add(1, Math.abs(heights.get(1)-heights.get(0)));
    
    if (N == 2) {
      return dp.get(1);
    }

    int cost;
    int firstJump;
    int secondJump;
    for (int i = 2; i < N; i++) {
      firstJump = Math.abs(heights.get(i)-heights.get(i-1));
      secondJump = Math.abs(heights.get(i)-heights.get(i-2));
      cost = Math.min(firstJump + dp.get(i-1), secondJump + dp.get(i-2));
      dp.add(i, cost);
    }
    return dp.get(N-1);
  }
}