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);
  }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz