#include <bits/stdc++.h>
using namespace std;
 
typedef long long lld;
const int NN = 1e5 + 5;
lld aa[NN], dp[NN];
int nn;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
        cin >> nn;
        for (int ii = 1; ii <= nn; ++ii)
            cin >> aa[ii];
        dp[1] = 0;
        dp[2] = abs(aa[2] - aa[1]);
        for (int ii = 3; ii <= nn; ++ii)
            dp[ii] = min(dp[ii - 1] + abs(aa[ii] - aa[ii - 1]), dp[ii - 2] + abs(aa[ii] - aa[ii - 2]));
        cout << dp[nn];
    return 0;
}