// Slower C++ solution:
#include <iostream>

#include <vector>

#include <cstdlib>

using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



const long long INF = 1LL << 60;



// 入力

int N;

long long h[100010];



// DP テーブル

long long dp[100010];



int main() {

    int N; cin >> N;

    for (int i = 0; i < N; ++i) cin >> h[i];



    // 初期化 (最小化問題なので INF に初期化)

    for (int i = 0; i < 100010; ++i) dp[i] = INF;



    // 初期条件

    dp[0] = 0;



    // ループ

    for (int i = 0; i < N; ++i) {

        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));

        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));

    }



    // 答え

    cout << dp[N-1] << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.778174895717016x):
//#include <bits/stdc++.h>

#include <iostream>

#include <map>

#include <cmath>

#include <ios>

#include <iomanip>

#include <algorithm>

#include <queue>

#include <numeric>

//#include <windows.h>

using namespace std;

template<class T> using V = vector<T>;

template<class T> using VV = V<V<T>>;

template<class T> using VVV = V<VV<T>>;

template<class T> using G = greater<T>;

template<class T1, class T2> using P = pair<T1, T2>;

using I = int;

using D = double;

using B = bool;

using C = char;

using S = string;

using LL = long long;

using LD = long double;

using ULL = unsigned long long;

using PII = P<I, I>;

using VPII = V<PII>;

using PLL = P<LL, LL>;

using VPLL = V<PLL>;

using VI = V<I>;

using VVI = VV<I>;

using VLL = V<LL>;

using VVLL = VV<LL>;

using VC = V<C>;

using VVC = VV<C>;

using VS = V<S>;

using VVS = VV<S>;

using VB = V<B>;

using VVB = VV<B>;

#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)

#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)

#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)

#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)

#define REPx(x, a) for(auto x : a)

#define ALL(a) a.begin(), a.end()

#define SORT(a) sort(ALL(a))

#define SORTR(a, type) sort(ALL(a), G<type>())

#define REVERSE(a) reverse(ALL(a))

#define SIZE(a) ((int)(a).size())

#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))

#define bit_check(bit, i) ((bit>>(i)) & 1)

#define setpre(n) fixed << setprecision((n))

#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)

#define MAX(a) *max_element(ALL(a))

#define MIN(a) *min_element(ALL(a))

#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()

#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()

#define INPUT(a) REPx(&x, a) cin >> x;

#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;

#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);

#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)

#define ENDL cout << endl;



template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<T> >;



template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}

template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}



const int INF = 2e9;

const LL MOD = 1e9 + 7;



int main()

{

  cin.tie(0);

  ios::sync_with_stdio(false);

  int N;

  cin >> N;

  VI h(N);

  INPUT(h);

  VI dp(N+2, INF);

  dp[0] = 0;

  REP(int, i, N)

  {

    chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]));

    chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]));

  }

  cout << dp[N-1] << endl;



  return 0;

}