#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define loop(i ,a,b) for(int i = a;i<b;i++)
#define rloop(i,a,b) for(int i = a ; i>b;i--)
#define loopll(i,a,b) for( long long int i = a; i<b;i++)
#define rloopll(i,a,b) for(long long int i = a; i>b;i--)
#define eb emplace_back
#define pii pair<int ,int>
#define pll pair<ll ,ll>
#define mk make_pair
#define intmin INT_MIN
#define intmax INT_MAX
#define cout(x) cout<<x<<" ";
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}

int mindig(string & s){
    int temp = INT_MAX;
//    int index = -1;
    for(int i = 0;i<s.size() ; i++){
        if(temp > s[i] - '0'){
            temp = s[i] - '0';
//            index = i;
        }
    }
    return temp;
}
//}
ll power(ll base ,ll exp){
    ll ans = 1;
    for(ll i = 1;i<=exp ; i++){
        ans *= base;
    }
    return ans;
}
//}
//
void factor(ll n ,set<ll> &s ){
        ll x = 2;
        while(n!= 1){
            if(n%x == 0){
                s.insert(x);
                n/= x;
            }
            else{
                x++;
            }
        }
    }

bool prime(int n){
    bool ok = true;
    for(int i = 2 ; i*i <= n ; i++){
        if(n%i == 0){ok =false ; break;}
    }
    return ok;
}
pair<ll ,ll > ass(pair<ll ,ll > &a , pair<ll ,ll> &b){
    pair<ll ,ll> x;
    x.first = -1e10;
    x.second = -1e10;
    if(a.second < b.first){return x;}
    if(b.second < a.first){return x;}
    if(a.first <= b.first){
        x.first = b.first;
        x.second = min(a.second , b.second);
    }
    else {
        x.first = a.first;
        x.second = min(a.second , b.second);
    }
    return x;
}
int MX = 100005;
vector<vector<int>> adj(MX , vector<int>());
vector<int> subt(MX , 1);
vector<bool> vis(MX, false);
vector<bool> vis2(MX, false);
vector<int> neigh(MX , 0);

int ans = 0;
int dfs(int x){
    if(vis[x] ){return 0;}
    vis[x]  = true;
    for(int i = 0;i<adj[x].size() ;i++){
        subt[x] += dfs(adj[x][i]);
    }
    return subt[x];
}

void dfs2(int x){
    if(vis2[x]){return;}
    vis2[x] = true;
    for(int i = 0;i<adj[x].size() ;i++){
        if(neigh[x] > 1 && subt[adj[x][i]]%2 == 0 && !vis2[adj[x][i]]){
            cout<<x<< " " <<adj[x][i]<< " " <<neigh[x]<< " " <<subt[adj[x][i]]<<endl;
            ans++;
            neigh[x]--;
            neigh[adj[x][i]]--;
//            cout<<"a "<< x<< " " <<adj[x][i]<<endl;
        }
        dfs(adj[x][i]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    bitset<10> s;
    int n;
    cin>>n;
    vector<int>h(n);
    loop(i , 0, n){
    cin>>h[i];}
    vector<int> minc(n , 0);
    for(int i = 0; i<n;i++){
        if(i == 0){
            minc[i] = 0;
        }
        else if (i == 1){
            minc[i] = abs(h[i] - h[i-1]);
        }
        else{
            minc[i] = min(minc[i-1] + abs(h[i-1]  - h[i]) , minc[i-2] + abs(h[i-2] - h[i]));
        }
    }
    cout<<minc[n-1]<<endl;
}





Measured memory_bytes: 7120