#include<bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<long long,long long>
#define read(a) scanf("%d",&a)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define clr(a) memset(a,0,sizeof(a))
#define MOD 10000000000
#define INF 10000000000000;

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ar[n+5];
    ll dp[MAX];
    clr(dp);
    ar[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&ar[i]);
    for(int i=2;i<=n;i++){
        ll p= dp[i-1]+abs(ar[i]-ar[i-1]);
        ll q= dp[i-2]+abs(ar[i]-ar[i-2]);
        dp[i]=min(p,q);
    }
    cout<<dp[n]<<endl;
    return 0;
}
