import java.util.Scanner; // 文字列を標準入力からscanする

public class Main{ 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  }
} import java.util.Scanner; // 文字列を標準入力からscanする Scanner java.util public class Main{ 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  }
} Main static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  } return_smaller {
    if(a > b){
      return b;
    }
      return a;
  } if(a > b){
      return b;
    } a > b a b {
      return b;
    } return b; b return a; a int a a int b b public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  } main {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = ""; str "" str = scan.nextLine() str scan.nextLine() scan.nextLine scan int N = Integer.parseInt(str); N Integer.parseInt(str) Integer.parseInt Integer str int[] hi = new int[N]; hi new int[N] N int[] dp = new int[N]; dp new int[N] N str = scan.nextLine() str scan.nextLine() scan.nextLine scan String[] strs2 = str.split(" "); strs2 str.split(" ") str.split str " " for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    } int i=0; int i=0; i 0 i<strs2.length i strs2.length strs2 strs2.length i++ i++ i {
      hi[i] = Integer.parseInt(strs2[i]);
    } {
      hi[i] = Integer.parseInt(strs2[i]);
    } hi[i] = Integer.parseInt(strs2[i]) hi[i] hi i Integer.parseInt(strs2[i]) Integer.parseInt Integer strs2[i] strs2 i scan.close() scan.close scan dp[0] = 0 dp[0] dp 0 0 for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    } int i = 1; int i = 1; i 1 i < N i N ++i ++i i {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    } {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    } if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      } i > 1 i 1 {
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      } dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2])) dp[i] dp i return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2])) return_smaller dp[i - 1] + Math.abs(hi[i] - hi[i - 1]) dp[i - 1] dp i - 1 i 1 Math.abs(hi[i] - hi[i - 1]) Math.abs Math hi[i] - hi[i - 1] hi[i] hi i hi[i - 1] hi i - 1 i 1 dp[i - 2] + Math.abs(hi[i] - hi[i - 2]) dp[i - 2] dp i - 2 i 2 Math.abs(hi[i] - hi[i - 2]) Math.abs Math hi[i] - hi[i - 2] hi[i] hi i hi[i - 2] hi i - 2 i 2 {
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      } dp[1] = dp[0] + Math.abs(hi[1] - hi[0]) dp[1] dp 1 dp[0] + Math.abs(hi[1] - hi[0]) dp[0] dp 0 Math.abs(hi[1] - hi[0]) Math.abs Math hi[1] - hi[0] hi[1] hi 1 hi[0] hi 0 System.out.println(dp[N-1]) System.out.println System.out System System.out dp[N-1] dp N-1 N 1 final String[] args args public class Main{ 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  }
} public class Main{ 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  }
} Main
import java.util.Scanner; // 文字列を標準入力からscanする

public class Main{ 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  }
}