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

public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
} Main static int h[]; h static int dp[]; dp public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	} main {
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int sz = scan.nextInt(); sz scan.nextInt() scan.nextInt scan h = new int[sz] h new int[sz] sz dp = new int[sz] dp new int[sz] sz for(int i = 0; i < sz; i++) h[i] = scan.nextInt(); int i = 0; int i = 0; i 0 i < sz i sz i++ i++ i h[i] = scan.nextInt(); h[i] = scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan dp[0] = 0 dp[0] dp 0 0 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 < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		} int i = 2; int i = 2; i 2 i < sz i sz i++ i++ i {
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		} {
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		} dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2])) dp[i] dp i Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2])) Math.min Math dp[i - 1] + Math.abs(h[i] - h[i - 1]) dp[i - 1] dp i - 1 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 - 2] + Math.abs(h[i] - h[i - 2]) dp[i - 2] dp i - 2 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 System.out.println(dp[sz - 1]) System.out.println System.out System System.out dp[sz - 1] dp sz - 1 sz 1 String[] args args public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
} public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
}
