// Original C++ solution (slower):
/*######################################################

#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########

#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########

#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#

#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########

#########~~######~~##~~##~~##~~##~~##~~###~~~~##########

######################################################*/

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("O3")

#define ll long long

#define str string

#define rtn return

#define endl '\n'

#define F first

#define S second

#define pb push_back

#define db long double

#define MOD 1000000007

#define INF 1e18

#define EPS 1e-15

#define pll pair <ll, ll>

#define vi vector<ll>

#define vpll vector<pll>

#define value_at find_by_order

#define index_of order_of_key

#define fill(a,v) memset(a,v,sizeof(a))

#define all(x) (x).begin(),(x).end()

#define rall(x) (x).rbegin(), (x).rend()

#define rep(i,n) for(ll i=0;i<n;++i)

#define per(i,n) for(ll i=n-1;i>=0;--i)

#define loop1(i, n) for (int i=1;i<=n;++i)

#define loop(i, begin, end) for (__typeof(end) i = (begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))

#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)



#define TRACE

#ifdef TRACE

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1){

    cerr << name << " = " << arg1 << '\n';

}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){

  const char* comma = strchr(names + 1, ',');

  cerr.write(names, comma - names) << " = " << arg1 << " |";

  __f(comma+1, args...);

}

#else

#define trace(...)

#endif



template<class T> void remin(T &a, T b) {a = min(a, b);}

template<class T> void remax(T &a, T b) {a = max(a, b);}

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



#define N 100005



int n;

int h[N];

int dp[N];



int solve(int i) {

  if (i == n - 1) rtn 0;

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

  dp[i] = INF;

  if (i < n - 1) {

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

  }

  if (i < n - 2) {

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

  }

  rtn dp[i];

}



int main() {

  FAST_IO;

  fill(dp, -1);

  cin >> n;

  rep(i, n) cin >> h[i];

  cout << solve(0);

  rtn 0;

}


// Optimized solution to the same problem (faster):
/*######################################################

#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########

#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########

#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#

#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########

#########~~######~~##~~##~~##~~##~~##~~###~~~~##########

######################################################*/

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

#pragma comment(linker, "/stack:268435456")

#pragma GCC optimize("O3")

#define ll long long

#define str string

#define rtn return

#define endl '\n'

#define F first

#define S second

#define pb push_back

#define db long double

#define MOD 1000000007

#define INF 1e18

#define EPS 1e-15

#define pll pair <ll, ll>

#define vll vector<ll>

#define vpll vector<pll>

#define value_at find_by_order

#define index_of order_of_key

#define fill(a,v) memset(a,v,sizeof(a))

#define all(x) (x).begin(),(x).end()

#define rall(x) (x).rbegin(), (x).rend()

#define rep(i,n) for(ll i=0;i<n;++i)

#define per(i,n) for(ll i=n-1;i>=0;--i)

#define loop1(i,n) for (int i=1;i<=n;++i)

#define loop(i,begin,end) for (__typeof(end) i =(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))

#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)



#define TRACE

#ifdef TRACE

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1){

    cerr << name << " = " << arg1 << '\n';

}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){

  const char* comma = strchr(names + 1, ',');

  cerr.write(names, comma - names) << " = " << arg1 << " |";

  __f(comma+1, args...);

}

#else

#define trace(...)

#endif





template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }

template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



#define N 100005



ll dp[N], h[N], n;



int main() {

  FAST_IO;

  cin >> n;

  rep(i, n) cin >> h[i];

  rep(i, n) {

    if (i > 0) {

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

    }

    if (i > 1) {

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

    }

  }

  cout << dp[n - 1];

  rtn 0;

}


// Fastest known solution for this problem: