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

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

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

#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)

#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)

#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

const int mod = (int)1e9 + 7;

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n;

int h[maxn], dp[maxn];



int main()

{

	n = read();

	rep(i, 1, n) h[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[1] = 0;

	rep(i, 1, n){

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

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

	}

	printf("%d\n", dp[n]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3671950823045123x):
/*****************************************************************\

IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL

|                                                                 |

|     Author     : Mahabub Rahman                                 |

|     Email      : mahabubrahman618@gmail.com                     |

|     University : Comilla University, Bangladesh                 |

|                  Department of Computer Science & Engineering   |

\*****************************************************************/





/*...................................Data_Types............................................*/

#include<bits/stdc++.h>



using namespace std;

#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)

#define       ll                  long long int

#define       ull                  unsigned long long int

#define       veci                 vector<int>

#define       vecc                 vector<char>

#define       vecs                 vector<string>

#define       vecl                 vector<long long int>

#define       vecp                 vector<  pair<int,int> >

#define       mapstrint            map< string , int >

#define       mapstrstr            map< string , string >

#define       mapint               map< int, int >

#define       pb                   push_back

#define       newline cerr << endl

#define       pob                  pop_back

#define       mp                   make_pair

#define       pii                  pair<int, int>

#define       F                    first

#define       S                    second

#define       sc(x)                scanf("%d",&x)

#define       sc2(xx,zz)           scanf("%d %d",&xx,&zz)

#define       scl(x)               scanf("%lld",&x)

#define       scl2(xx,zz)          scanf("%lld %lld",&xx,&zz)

#define       pf                   printf

#define       min3(a,b,c)          min(a,b<c?b:c)

#define       max3(a,b,c)          max(a,b>c?b:c)

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

///=============== Debugging ============================///

#define       debug(x) cerr << #x << " = " << x << endl

#define       debug2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;

#define       debug3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;

#define       debug4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;

//#define f(x) (64 - __builtin_clzll(x))

///============ CONSTANT ===============///

#define mx9   1000000007

#define mx7   10000007

#define mx6   2000006

#define mx5   200005

#define inf   1<<30                                           //infinity value

#define eps   1e-9

#define mod   mx9

///==============================TEMPLATES===============================///



long double PI = acosl(-1);

bool compare_int(int a, int b){return (a>b);} //This function is use for descending order.

bool compare_string (string a, string b){return a.size()<b.size();}

bool compare_pair(const pair<int,int> &a,

                    const pair<int,int> &b){if(a.second==b.second)return a.first<b.first; else return (a.second > b.second);}

bool cmp(pair<string ,int > x , pair<string ,int > y){return (x.S < y.S);}

///=====================Graph Moves================///

//const int fx[]= {+1,-1,+0,+0};

//const int fy[]= {+0,+0,+1,-1};

//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move

//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move

//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move



///=====================Bitmask===================///

//int Set(int N,int pos){return N=N | (1<<pos);}

//int reset(int N,int pos){return N= N & ~(1<<pos);}

//bool check(int N,int pos){return (bool)(N & (1<<pos));}



///========================================FUNCTION=========================================///

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

//ll bigmod(ll a, ll b, ll m){if(b==0) return 1%m;ll x=bigmod(a, b/2, m);x=(x*x)%m;if(b%2==1)x=(x*a)%m;return x;}

//bool flag[mx5];veci prime;

//void sieve(){prime.pb(2);for(ll i=3; i*i<=mx5; i+=2){if(flag[i]) continue;for(ll j=i*i; j<=mx5; j+=i+i) flag[j]=true;}for(ll i=3; i<=mx5; i+=2) if(!flag[i]) prime.pb(i);}

//ll fact(ll n){if(n==0 or n==1)return 1; else return n*fact(n-1);}

void NA(){printf("NO\n");exit(0);}

void YA(){printf("YES\n");exit(0);}



///=================START_FROM_HERE=====================///



int32_t main()

{

    ///Don't see test case until get 7/8 times wrong submission..!!

    ///Try to make Corner, Even, Odd or Prime case..!!

    FastIO;

    int n;

    cin >> n;

    int a[n+1], ans[n+2]={0};

    for(int i=0; i<n; i++) cin >> a[i];

    for(int i=n-2; i>=0; i--)

    {

        if(i==n-2)

        {

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

            continue;

        }

        ans[i] = min(abs(a[i]-a[i+1])+ans[i+1], abs(a[i]-a[i+2])+ans[i+2]);

    }

    cout << ans[0] << endl;



}

///Created: