import java.io.*;
public class Main{
 
  public static int findCost(int arr[],int i,int dp[])
  {
	int n=arr.length;
 
    if(i>=n-1)
      return 0;
    int ans1=Integer.MAX_VALUE,ans2=Integer.MAX_VALUE;
    if(dp[i]==Integer.MAX_VALUE) {
    if((i+1)<n)
    ans1=Math.abs(arr[i]-arr[i+1])+findCost(arr,i+1,dp);
    if((i+2)<n)
    ans2=Math.abs(arr[i]-arr[i+2])+findCost(arr,i+2,dp);
    dp[i]=Math.min(ans1, ans2);}
    return dp[i];
    
  }
  
  public static void main(String[] args) throws IOException
  {
     
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    String line=br.readLine();
    String str[]=line.trim().split("\\s+");
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
    {
      arr[i]=Integer.parseInt(str[i]);
     // System.out.println(arr[i]);
    }
    int dp[]=new int[n];
    for(int i=0;i<n;i++)
    	dp[i]=Integer.MAX_VALUE;
    System.out.print(findCost(arr,0,dp));
    
  }
}
/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