// Slower C++ solution:
/**       In the name of Allah, the Gracious, the Merciful.

*               Praise be to Allah, Lord of the Worlds.

*               **************************************

*

*    I have not failed, I have just found 1000 WAYS that won't work.

*                 __________________________________

*                  Author  : Abd El-Twab  M. Fakhry

*                 __________________________________

*/



#include <ext/rope>

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>



#define  print(arr, l, r)    for(int i = (l); i < (r); cout << arr[i++] << " \n"[i == r])

#define  read(arr, l, r)     for(int i = (l); i < (r); cin >> arr[i++])

#define  repr(i, r, l)       for (int i = r; i > l; i--)

#define  rep(i, l, r)        for (int i = l; i < r; i++)

#define  Unique(n)           (n).erase(unique(all(n)), (n).end())

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

#define  RT(n)               return cout << (n) << endl, 0;

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

#define  endl                '\n'

#define  D(x)                cout << #x << " = " << (x) << '\n'

#define  F                   first

#define  S                   second

#define  PB                  push_back

#define  EB                  emplace_back

#define  lsb(x)              (x & -x)

#define  get(n)              find_by_order(n)

#define  sqrt(n)             sqrtl(n)

#define  pow(a, b)           powl(a, b)

#define  indexOf(n)          order_of_key(n)

#define  isPowerOfTwo(x)     (x && !(x & (x - 1)))



using namespace std;

using namespace __gnu_pbds;

using namespace __gnu_cxx;



typedef long long            ll;

typedef unsigned long long   ull;



/**---------------------->>  Constants  <<-----------------------**/



const double    Pi      = 2 * acos(0.0),    Euler = 2.71828182845904523536,

                Epsln   = 1e-9,           GoldenR = (1 + sqrtl(5.0)) / 2;



const ll        MgcPrim = 2305843009213693951;

const int       MxsZ    = (int)1e5 + 9,        oo = 0x3f3f3f3f,

 		        ModB2   = (1 << 30) + 7,   ModBT7 = (int)1e9 + 7, ModBT = (int)1e9;



/**---------------->>  Functions & Shortcuts  <<-----------------**/



template <class T>

T Gcd(T a, T b) { return b ? Gcd(b, a % b) : a; }



template <class T>

T Lcm(T a, T b) { return a / Gcd(a, b) * 1ll * b; }



template <class T> /** Phi(a * b) = Phi(a) * Phi(b) where a and b Prime Factors and k their power **/

T Phi(T a, T k) { return pow(a, k - 1) * (a - 1); }



template <class T>

using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;



template <class T>

using matrix = vector < vector <T> >;



template <class T>

using min_heap = priority_queue < T, vector <T>, greater <T> >;



/** Watch **/



template <class T>

string ToString(T x) { stringstream sout; sout << x; return sout.str(); }



#ifdef BFS

int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dx4[4] = { 0, 0, 1,-1};

int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 }, dy4[4] = { 1,-1, 0, 0};

#endif // BFS



/**------------------>>  Fast input / output  <<-----------------**/



void Fast()

{

    cin.sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    cin.exceptions(cin.failbit);

}



/**----------------->>  input / output Files  <<-----------------**/



void File()

{

    #ifdef FIO

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

    freopen("output.out", "w", stdout);

   	#endif // FIO

}



/**------------------>>  Initialization gap  <<------------------**/



int n, a[MxsZ], dp[MxsZ];



int Frog(int nx)

{

    if(~dp[nx]) return dp[nx];

    return dp[nx] = min(Frog(nx - 1) + abs(a[nx] - a[nx - 1]), Frog(nx - 2) + abs(a[nx] - a[nx - 2]));

}



inline void Solve()

{

    memset(dp, -1, sizeof dp);



    cin >> n; read(a, 0, n);

    dp[0] = 0; dp[1] = abs(a[0] - a[1]);



    cout << Frog(n - 1) << endl;

}



/**------------------------->>  Main  <<-------------------------**/



int main()

{

    Fast(); File(); Solve();

}


// Faster C++ solution for the same problem (measured speedup: 1.3915340755563892x):
#include <iostream>

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

#define For(i,a,b,c) for(int i = a;i < b;i+=c)

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

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

#define mem(a,s) memset(a,s,sizeof a)

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//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;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[1]<<'\n';

    return 0;

}