#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
const int MAX = 1e5 + 9;
ll arr[MAX], n,dp[MAX];
int main() {
    fast();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    dp[1]=abs(arr[1]-arr[0]);
    for (int j = 2; j < n; ++j) {
        dp[j]=min(dp[j-1]+abs(arr[j]-arr[j-1]),dp[j-2]+abs(arr[j]-arr[j-2]));
    }
    cout<<dp[n-1];
}