#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const int N = 1e5 + 50;
const double EPS = 1e-8;
const long long mod = 1e9 + 7;

const int dx[] = {0,0,1 , -1,1 ,-1 , 1 , -1};
const int dy[] = {1,-1,0 , 0,1 , -1 , -1 , 1};



int dp[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n , h[N];
    cin >> n;
    for(int i = 0; i < n; ++i)
            cin >> h[i];
    // state : pos
    // trans : dp[pos] = min(dp[pos - 1] , dp[pos - 2] )
    // base  : dp[0] = 0 , dp[1] = abs(h[1]-h[0]);
   
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int pos = 2; pos < n; ++pos)
            dp[pos] = min(dp[pos - 1] + abs(h[pos] - h[pos - 1])
                    , dp[pos - 2] + abs(h[pos] - h[pos - 2]));
    cout << dp[n - 1] << '\n';
    return 0;
}
