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