#include<bits/stdc++.h>
using namespace std;
int dp[100000];
count(int h[],int n,int sum){
    if(n==1){
        return sum; 
    }
   // cout<<n<<" "<<sum<<endl;
    /*if(dp[n]!=-1){
        return dp[n];
    }
    else{*/
        if(n==3){
            return dp[n]=min(count(h,n-1,sum+abs(h[n]-h[n-1])),sum+abs(h[n]-h[n-2]));
        }
        if(n==2){
            return dp[n]=count(h,n-1,sum+abs(h[n]-h[n-1]));
        }
        else{
            return dp[n]=min(count(h,n-1,sum+abs(h[n]-h[n-1])),count(h,n-2,sum+abs(h[n]-h[n-2])));
        }
    
}
int main(){
    int n;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    for(int i=0;i<100000;i++){
        dp[i]=-1;
    }
    cout<<count(h,n,0);
}