#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 1;

int n, h[MAXN];

int main(){

    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    int dp[n + 5];
    for(int i = 0; i < n; i++) dp[i] = 1e9;
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        if(i > 0) dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;

    return 0;
}
