// Slower C++ solution:
/**

 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>

 * @created     : Thursday August 13, 2020

 */



#include <bits/stdc++.h>



using namespace std;



#define endl '\n'

#define all(x) (x).begin(), (x).end()

#define rall(x) (x).rbegin(), (x).rend()

#define ms(arr, value) memset(arr, value, sizeof arr)

#define ll    int64_t



#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



string to_string(string s) {

    return '"' + s + '"';

}



string to_string(bool b) {

    return (b ? "true" : "false");

}



// add template here



template <typename A>

string to_string(A v) {

    bool first = true;

    string res = "{";

    for (const auto &x : v) {

        if (!first) {

            res += ", ";

        }

        first = false;

        res += to_string(x);

    }

    res += "}";

    return res;

}



template<class T>

void println(const T &data) {

#ifndef ONLINE_JUDGE

    cout << to_string((T)data) << endl;

#endif

}





const int oo  = (int)(1e9);

const ll lloo  = (ll)(1e18);



const int N = 1e5 + 10;



class Task {

public:

    int n;

    vector<int> A;



    ll dp[N];



    ll go(int index) {

        if(index > n) return 0LL;

        if(index == n) {

            return 0LL;

        }



        ll &ans = dp[index];

        if(ans != -1) return ans;



        ll x = oo;

        ll y = oo;



        if(index+1 <= n) {

            x = abs(A[index]-A[index+1]) + go(index + 1);

        }

        

        if(index+2 <= n) {

            y = abs(A[index]-A[index+2]) + go(index + 2);

        }

        ll mn = min(x, y);

        if(mn == oo) {

            ans = 0;

            return ans;

        }

        ans = min(x, y);

        return ans;

    }



    ll solveOne(istream &in, ostream &out) {

        in >> n;

        A.resize(n+1);

        for(int i = 1; i <= n; ++i){

            in >> A[i];

        }

        memset(dp, -1, sizeof dp);

        ll ans = go(1);

        return ans;  

    }

    

    void solve(istream &in, ostream &out) {

        int t = 1;

        while(t--) {

            out << solveOne(in, out) << endl;

        }

    }

};



auto main() -> int {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    

    Task solver;

    istream &in(cin);

    ostream &out(cout);

    solver.solve(in, out);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.8024240309704123x):
#include<bits/stdc++.h>

#define ll          long long int

#define ld          long double

#define pb          push_back

#define mp          make_pair

#define ff          first

#define se          second

#define scan(n)     scanf("%lld", &n);

#define print(n)    printf("%lld\n", n);

#define fd(n)       fixed<<setprecision(n)

#define MAX         1000000000000000000

#define MAXN        100005

#define LOG         19

#define mod         1000000007

using namespace std;





int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll n,i;

    scan(n);

    ll a[n],dp[n];

    for(ll i=0;i<n;i++){

        scan(a[i]);        

    }

    for(i=0;i<n;i++){

        dp[i]=0;

    }

    dp[0]=0;

    for(i=0;i<n;i++){

        if(i==1){

            dp[i]=abs(a[i]-a[i-1]);

        }

        else if(i>=2){

            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]));

        }

        // cout<<dp[i]<<" ";

    }

    cout<<dp[n-1];

}