#include <bits/stdc++.h>

using namespace std;
const int maxn = 2e5+2;
const int mod = 1e9+7;
const int inf = 1e9;

typedef long long ll;

int n;
int arr[maxn], dp[maxn];

int solve_dp (int pos){
    if (pos > n) return inf;
    if (pos == n - 1) return 0;

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

    int ans = inf;
    ans = min(ans, solve_dp(pos + 1) + abs(arr[pos + 1] - arr[pos]));
    ans = min(ans, solve_dp(pos + 2) + abs(arr[pos + 2] - arr[pos]));

    return dp[pos] = ans;
}

int main(){

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

    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }

    memset(dp, -1, sizeof dp);

    cout << solve_dp(0) << "\n";

    return 0;
}
