#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define MOD (long long int )1e9+7
using namespace std;

typedef long long int ll;

// bool cmp(const pair<int, set<int>> a, const pair<int, set<int>> b) {
//     return a.second.size() > b.second.size();
// }

bool cmp(const pair<int, int> a, const pair<int, int> b) {
    return a.first < b.first;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

bool isPrime(int n) {
    for (int i=2; i*i <= n; i++) {
        if (n%i == 0) {
            return false;
        }
    }
    return true;
}

void bfs(vector<vector<int>> graph, int src, int dest, vector<int> &pred) {
    queue<int> q;
    vector<bool> visited(graph.size()+1, false);
    q.push(src);
    visited[src] = true;
    while (!q.empty()) {
        int curr = q.front();
        // cout << curr << " ";
        q.pop();
        for (int i: graph[curr]) {
            if (!visited[i]) {
                q.push(i);
                visited[i] = true;
                pred[i] = curr;
                if (i == dest) {
                    return;
                }
            }
        }

    }
    // cout << endl;
}

ll nCr(int n, int r) {
    if (n == r) {
        return 1;
    }
    ll ans = 1;
    if (n > r) {
        int mn = min(n-r, r);
        int mx = max(n-r, r);
        for (int i=n; i>mx; i--) {
            ans = ans*i;
        }
        for (int i=1; i<=mn; i++) {
            ans /= i;
        }
        return ans;
    }
    return 0;
}

vector<int> sieve(int n) {
    vector<bool> is_prime(n+1, true);
    vector<int> prime;
    is_prime[0] = is_prime[1] = false;
    for (int i=2; i<=n; i++) {
        // cout << i << endl;
        if (is_prime[i] && (ll)i*i <= n) {
            for (int j=i*i; j<=n; j+=i) {
                // cout << j << endl;
                is_prime[j] = false;
                // cout << i << " " << j << endl;
            }
        } 
    }
    for (int i=0; i<=n; i++) {
        if (is_prime[i])
            prime.push_back(i);
    }
    return prime;
}

vector<int> nextSmallerElements(vector<int> nums) {
    int n = nums.size();
    stack<int> stk;
    stk.push(0);
    vector<int> ind(n);
    for (int i=1; i<n; i++) {
        if (stk.empty()) {
            stk.push(i);
        }
        else {
            while(!stk.empty() && nums[stk.top()] > nums[i]) {
                ind[stk.top()] = i;
                stk.pop();
            }
            stk.push(i);
        }
    }
    while (!stk.empty()) {
        ind[stk.top()] = -1;
        stk.pop();
    }
    // for (int i=0; i<n; i++) {
    //     if (ind[i] != -1)
    //         ind[i] = nums[ind[i]];
    // }
    return ind;
}

set<string> seq;

void sub(string s, string curr, int ind) {
    if (ind >= s.length()) {
        seq.insert(curr);
        return;
    }
    sub(s, curr+s[ind], ind+1);
    sub(s, curr, ind+1);
}

int main() {

    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i=0; i<n; i++) cin >> nums[i];
    vector<int> dp(n, 0);
    dp[0] = 0;
    for (int i=1; i<n; i++) {
        if (i == 1) {
            dp[1] = (int)abs(nums[1]-nums[0]);
        }
        else {
            dp[i] = min((int)abs(nums[i]-nums[i-1])+dp[i-1], (int)abs(nums[i]-nums[i-2])+dp[i-2]);
        }
    }
    // printV(dp);
    cout << dp[n-1] << endl;
    //l time(&end);
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}

Measured memory_bytes: 1024