import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

		System.out.println(dp[t-1]);
	}
} import java.util.*; util.* java public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

		System.out.println(dp[t-1]);
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

		System.out.println(dp[t-1]);
	} main {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

		System.out.println(dp[t-1]);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int t = sc.nextInt(); t sc.nextInt() sc.nextInt sc int[] arr = new int[t]; arr new int[t] t for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<t i t i++ i++ i {
			arr[i] = sc.nextInt();
		} {
			arr[i] = sc.nextInt();
		} arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int[] dp = new int[t]; dp new int[t] t dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(arr[1]-arr[0]) dp[1] dp 1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		} int i=2; int i=2; i 2 i<t i t i++ i++ i {
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		} {
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		} dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2])) dp[i] dp i Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2])) Math.min Math dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 dp[i-2]+Math.abs(arr[i]-arr[i-2]) dp[i-2] dp i-2 i 2 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 System.out.println(dp[t-1]) System.out.println System.out System System.out dp[t-1] dp t-1 t 1 String[] args args public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

		System.out.println(dp[t-1]);
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

		System.out.println(dp[t-1]);
	}
} Main
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] arr = new int[t];
		for(int i=0;i<t;i++)
		{
			arr[i] = sc.nextInt();
		}

		int[] dp = new int[t];

		dp[0] = 0;
		dp[1] = Math.abs(arr[1]-arr[0]);

		for(int i=2;i<t;i++)
		{
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		}

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