// 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.7854217454630121x):
#include <bits/stdc++.h>



#define Fast cin.tie(0), ios::sync_with_stdio(0)

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

#define louisfghbvc int t; cin >> t; while(t--)

#define sz(x) (int)(x).size()

using namespace std;

typedef long long LL;

typedef pair<LL, LL> ii;

typedef vector<LL> vi;



template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }



void dbg_out() { cerr << "\n"; }

template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }



void solve(){

    int n;

    cin >> n;

    vi h(n);

    for(auto &it: h) cin >> it;



    vi dp(n, 1e9+5);

    dp[0] = 0;

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

        for(int j = max(i-2, 0); j < i; ++j){

            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));

        }

    }

    cout << dp[n-1] << "\n";

}



int main()

{

    Fast;

    //louisfghbvc{

        solve();

    //}

    return 0;

}