// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+1;



vector<int> v(N, 0);

vector<int> memo(N, -1);



int cost(int pos, int n){

    if (memo[pos]!=-1) return memo[pos];

    else if (pos == n) return 0;

    else if (pos == n-1) return (abs(v[n-1] - v[n]));

    else {

        memo[pos] = min(abs(v[pos] - v[pos + 1]) + cost(pos+1, n), abs(v[pos]-v[pos + 2]) + cost(pos+2, n));

        return memo[pos];

    }

}



int main(){

    int n; cin >> n;

    

    for (int i = 1; i!=n+1; i++) cin >> v[i];

    cout << cost(1, n) << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7432098735971564x):
//                                 Alisher_2211

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>

# define  long          long long

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

# define  allr(vc)      vc.rbegin(),vc.rend()

# define  pb            push_back

# define  fi            first 

# define  se            second

# define  pi            pair <long, long>    

# define  lcm(a, b)     (a * b) / __gcd(a, b)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;

const long N = 100100;

void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}

long dp[N];

long n;

void solve(){

    cin >> n;

    vector <long> v(n + 1), d(n);

    for (int i = 1; i <= n; ++i) cin >> v[i];

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

        long o1 = dp[i - 1] + abs( v[i] - v[i - 1] );

        long o2 = dp[i - 2] + abs( v[i] - v[i - 2] );

        if( i == 2 ) o2 = 1e9 + 100;

        dp[i] = min(o1, o2);

    }

    cout << dp[n];

}

int32_t main(){

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 

        long T = 1;

        //cin >> T;

        while( T-- ){

            solve();

            cout<<'\n';

        }

cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

}