/***************************************************
 * Problem Name : A - Frog 1.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-01-26
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FileRead freopen ("/home/saikat/Desktop/logN/input.txt", "r", stdin);
#define FileWrite freopen ("/home/saikat/Desktop/logN/output.txt", "w", stdout);
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int n;
int ar[MAX];
int dp[MAX][3];

/*int fun (int i, int cost) {
    if(i>=n) return INF;
    if (i >= n -1) {
        return dp[i] = cost;
    }

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

    int ret1 = INF, ret2 = INF;

    for(int j = 1; j<=2; j++){
        int newCost = cost;
    }


    //~ if (i + 1 < n) {
        ret1 = fun (i + 1,cost + abs (ar[i] - ar[i + 1]) );
    //~ }

    //~ if (i + 2 < n) {
        ret2 = fun (i + 2,cost + abs (ar[i] - ar[i + 2]) );
    //~ }

    return dp[i] = min (ret1, ret2);
    //~ return min (ret1, ret2);
}*/

int fun (int n) {
    for (int i = 1; i <= 2; i++) {
        dp[0][i] = INF;
    }

    for (int i = 1; i < n; i++) {
        dp[i][1] =  INF;
        dp[i][2] =  INF;
    }

    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[1][1] = abs (ar[1] - ar[0]);
    dp[1][2] = INF;

    for (int i = 2; i < n; i++) {
        int x1 = min (dp[i - 1][1], dp[i - 1][2]);
        x1 += abs (ar[i] - ar[i - 1]);
        int x2 = min (dp[i - 2][1], dp[i - 2][2]);
        x2 += abs (ar[i] - ar[i - 2]);
        dp[i][1] = min (x1, x2);
        dp[i][2] = min (x1, x2);
    }

    //~ for(int i = 0; i<n; i++){
    //~ cout << dp[i][1] << " " << dp[i][2] << "\n";
    //~ }
    return min (dp[n - 1][1], dp[n - 1][2]);
}
int main () {
    //~ __FastIO;
    cin >> n;

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

    int ans = fun (n);
    //~ debug;
    //~ SET (dp, -1);
    //~ int ans = fun (0, 0);
    //~ SET(dp, -1);
    //~ int ans2 = fun(0, 2, 0);
    //~ int  ans = min(ans1, ans2);
    cout << ans << "\n"    ;
    return 0;
}


Measured memory_bytes: 1792