import java.util.*;

public class Main{
	public static int n;
	public static int [] arr;
	public static int[] dp;
	public static int minCost(int pos)
	{
		if(pos>=n-1) 
			return 0;
		if(dp[pos]!=-1)
			return dp[pos];
		int onestep=Integer.MAX_VALUE;
		int twostep=Integer.MAX_VALUE;
		if(pos+1<n)
		{
			onestep=Math.abs(arr[pos]-arr[pos+1])+minCost(pos+1);
		//	System.out.println(onestep);
		}
		if(pos+2<n)
		{
			twostep=Math.abs(arr[pos]-arr[pos+2])+minCost(pos+2);
			//System.out.println(twostep);
		}
		return dp[pos]=Math.min(onestep, twostep);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		arr=new int[n];
		dp=new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		Arrays.fill(dp,-1);
		System.out.println(minCost(0));
		
	}

}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz