import java.io.*;
import java.util.*;

class Main {
  static final Scanner in = new Scanner(System.in);
  static int N, K;

  static int[] h;
  static int dp[];
  static final int MOD = 1000000007;
  static int[] pre;

  public static void main(String[] args) throws Exception {
    N = in.nextInt();
    h = new int[N];
    dp = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++){ h[i] = in.nextInt();
  }
  Arrays.fill(dp,-1);

    System.out.println(F(N-1));
  }

  static int F(int i){
    if(i == 0)
      return 0;
    
    if(i == 1)
      return Math.abs(h[0] - h[1]); 
    
    if(dp[i] != -1)
      return dp[i];  
      
    int a = F(i - 1) + Math.abs(h[i-1] - h[i]);
    int b = F(i - 2) + Math.abs(h[i-2] - h[i]);

    dp[i] = Math.min(a,b);
    return dp[i];
  }
} import java.io.*; io.* java import java.util.*; util.* java class Main {
  static final Scanner in = new Scanner(System.in);
  static int N, K;

  static int[] h;
  static int dp[];
  static final int MOD = 1000000007;
  static int[] pre;

  public static void main(String[] args) throws Exception {
    N = in.nextInt();
    h = new int[N];
    dp = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++){ h[i] = in.nextInt();
  }
  Arrays.fill(dp,-1);

    System.out.println(F(N-1));
  }

  static int F(int i){
    if(i == 0)
      return 0;
    
    if(i == 1)
      return Math.abs(h[0] - h[1]); 
    
    if(dp[i] != -1)
      return dp[i];  
      
    int a = F(i - 1) + Math.abs(h[i-1] - h[i]);
    int b = F(i - 2) + Math.abs(h[i-2] - h[i]);

    dp[i] = Math.min(a,b);
    return dp[i];
  }
} Main static final Scanner in = new Scanner(System.in); in new Scanner(System.in) static int N N K; K static int[] h; h static int dp[]; dp static final int MOD = 1000000007; MOD 1000000007 static int[] pre; pre public static void main(String[] args) throws Exception {
    N = in.nextInt();
    h = new int[N];
    dp = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++){ h[i] = in.nextInt();
  }
  Arrays.fill(dp,-1);

    System.out.println(F(N-1));
  } main {
    N = in.nextInt();
    h = new int[N];
    dp = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++){ h[i] = in.nextInt();
  }
  Arrays.fill(dp,-1);

    System.out.println(F(N-1));
  } N = in.nextInt() N in.nextInt() in.nextInt in h = new int[N] h new int[N] N dp = new int[N] dp new int[N] N int old_sum = 0; old_sum 0 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] = in.nextInt() h[i] h i in.nextInt() in.nextInt in Arrays.fill(dp,-1) Arrays.fill Arrays dp -1 1 System.out.println(F(N-1)) System.out.println System.out System System.out F(N-1) F N-1 N 1 String[] args args static int F(int i){
    if(i == 0)
      return 0;
    
    if(i == 1)
      return Math.abs(h[0] - h[1]); 
    
    if(dp[i] != -1)
      return dp[i];  
      
    int a = F(i - 1) + Math.abs(h[i-1] - h[i]);
    int b = F(i - 2) + Math.abs(h[i-2] - h[i]);

    dp[i] = Math.min(a,b);
    return dp[i];
  } F {
    if(i == 0)
      return 0;
    
    if(i == 1)
      return Math.abs(h[0] - h[1]); 
    
    if(dp[i] != -1)
      return dp[i];  
      
    int a = F(i - 1) + Math.abs(h[i-1] - h[i]);
    int b = F(i - 2) + Math.abs(h[i-2] - h[i]);

    dp[i] = Math.min(a,b);
    return dp[i];
  } if(i == 0)
      return 0; i == 0 i 0 return 0; 0 if(i == 1)
      return Math.abs(h[0] - h[1]); i == 1 i 1 return Math.abs(h[0] - h[1]); Math.abs(h[0] - h[1]) Math.abs Math h[0] - h[1] h[0] h 0 h[1] h 1 if(dp[i] != -1)
      return dp[i]; dp[i] != -1 dp[i] dp i -1 1 return dp[i]; dp[i] dp i int a = F(i - 1) + Math.abs(h[i-1] - h[i]); a F(i - 1) + Math.abs(h[i-1] - h[i]) F(i - 1) F i - 1 i 1 Math.abs(h[i-1] - h[i]) Math.abs Math h[i-1] - h[i] h[i-1] h i-1 i 1 h[i] h i int b = F(i - 2) + Math.abs(h[i-2] - h[i]); b F(i - 2) + Math.abs(h[i-2] - h[i]) F(i - 2) F i - 2 i 2 Math.abs(h[i-2] - h[i]) Math.abs Math h[i-2] - h[i] h[i-2] h i-2 i 2 h[i] h i dp[i] = Math.min(a,b) dp[i] dp i Math.min(a,b) Math.min Math a b return dp[i]; dp[i] dp i int i i
import java.io.*;
import java.util.*;

class Main {
  static final Scanner in = new Scanner(System.in);
  static int N, K;

  static int[] h;
  static int dp[];
  static final int MOD = 1000000007;
  static int[] pre;

  public static void main(String[] args) throws Exception {
    N = in.nextInt();
    h = new int[N];
    dp = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++){ h[i] = in.nextInt();
  }
  Arrays.fill(dp,-1);

    System.out.println(F(N-1));
  }

  static int F(int i){
    if(i == 0)
      return 0;
    
    if(i == 1)
      return Math.abs(h[0] - h[1]); 
    
    if(dp[i] != -1)
      return dp[i];  
      
    int a = F(i - 1) + Math.abs(h[i-1] - h[i]);
    int b = F(i - 2) + Math.abs(h[i-2] - h[i]);

    dp[i] = Math.min(a,b);
    return dp[i];
  }
}
