import java.util.*;
import java.io.*;
 
public class Main{
public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    }
  
  public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    }
  
  public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  }
} Main public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    } main {
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] h = new int[n]; h new int[n] n for(int i=0;i<n;i++) h[i] = sc.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i h[i] = sc.nextInt(); h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc int ans = solve(n,h); ans solve(n,h) solve n h System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  } solve {
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  } int[] dp = new int[n]; dp new int[n] n dp[1] = Math.abs(h[1]-h[0]) dp[1] dp 1 Math.abs(h[1]-h[0]) Math.abs Math h[1]-h[0] h[1] h 1 h[0] h 0 for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]); int i=2; int i=2; i 2 i<n i n i++ i++ i dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]); dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]) dp[i] dp i Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]) Math.min Math Math.abs(h[i]-h[i-1])+dp[i-1] 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-1] dp i-1 i 1 Math.abs(h[i]-h[i-2])+dp[i-2] 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 dp[i-2] dp i-2 i 2 return dp[n-1]; dp[n-1] dp n-1 n 1 int n n int h[] h public class Main{
public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    }
  
  public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  }
} public class Main{
public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    }
  
  public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  }
} Main
import java.util.*;
import java.io.*;
 
public class Main{
public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    }
  
  public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  }
}