#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#define ll long long
#define sz 100005
using namespace std;
ll a[sz] , sum;
ll dp[sz];
ll solve(ll n , ll i){
   if(i<n){
        dp[i] = min(dp[i-2]+(abs(a[i-2] - a[i])),dp[i-1]+(abs(a[i-1] - a[i])));
        solve(n,i+1);
   }
   else return dp[n-1];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i , j , n;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    dp[1] = abs(a[1]-a[0]);
    ll res = solve(n,2);
    cout<<res<<endl;
    return 0;
}
