// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

/*                   وتزودوا فإن خير الزاد التقوى                    */

/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */

#include <bits/stdc++.h>

#include<unordered_map>

#include<iomanip>

#include<fstream>

using namespace std;

#include<iostream>

#define endl '\n'

#define ll long long

#define ull unsigned long long

#define dll double

#define PI acos(-1)

#define watch(x) cout<<#x<<" = { "<<x<<" }\n"

#define sz(n) n.size()

#define M_Sayed fast() 

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

#define allr(v) v.rbegin(),v.rend()

#define RT(v) return cout<<v,0

int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

const double EPS = (1e-7);

ll Ceil(ll x, ll y) { return (x + y - 1) / y; }

void run() {

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	//freopen("output.txt", "w", stdout);

#else

#endif

}

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }

ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

ll power(ll x, ll y, ll mod) {

	if (y == 0) return 1;

	if (y == 1) return x % mod;

	ll r = power(x, y >> 1, mod);

	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;

}

void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }

ll n, m, k,su,cnt;

ll vis[100009];

vector<ll>v;

ll Jum(int x) {

	if (x+1 == n)

		return 0;

	ll &ret = vis[x];

	if (~ret)return ret;

	 ret = abs(v[x] - v[x + 1])+Jum(x + 1) ;

	for (int i = 2; i <=k; i++) {

		if(i+x<n)ret = min(ret,Jum(x + i) + abs(v[x] - v[x + i]));

	}

	return ret;

}

int main()

{

	//run();

	M_Sayed;

	cin >> n ;

	memset(vis, -1, sizeof vis);

	v.resize(n);

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

		cin >> v[i];

	}

	k = 2;

	RT(Jum(0));

}

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

using namespace  std ;

typedef long long  ll;

typedef pair<ll, ll> Pll;

#define F first

#define S second

#define MP make_pair

#define PB push_back

#define rad(X) cout << (X) << endl

#define ASH(X) cout << (X) << " "

#define debug(x) cout << #x << " " << x << endl;

#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;

#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)

#define cir(I,B,A) for(ll I = (A); I >=(B); I--)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MS1(X) memset((X), -1, sizeof((X)))

#define SORT(c) (sort(c.begin(),c.end()))

#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))

#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())

#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)

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

template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}

ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};

//vector<ll>a,b,c;

map<ll,ll>m1,m2,m3;

ll DP[100005];



/************************************************/



void Execute()

{

      ll n, nb, k, q, a, b, c, l, r, d, x, y, p, m;

      std::cin >> n;

      ll ar[n];

      FOR(i,0,n-1) cin >> ar[i];



      DP[0] = 0;

      DP[1] = abs(ar[1] - ar[0]);



      FOR(i,2,n-1)

      {

            a = abs(ar[i] - ar[i-1]) + DP[i-1];

            b = abs(ar[i] - ar[i-2]) + DP[i-2];

        DP[i] = min(a,b);

      }

      std::cout << DP[n-1] << '\n';

}



int32_t main()

{

    //#ifndef ONLINE_JUDGE

    //freopen("input.txt", "r", stdin);

    //#endif



    FAST();

    //CASES



        Execute();



}