// Slower C++ solution:
///*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*///



//#pragma GCC optimize("Ofast")

//#pragma GCC target("avx,avx2,fma")

//#pragma GCC optimization ("unroll-loops")



#include <bits/stdc++.h>

using namespace std;

#define ln '\n'

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

#define inp2(a,b) scanf("%lld %lld",&a,&b)



#define f0(i,b) for(int i=0;i<(b);i++)

#define f1(i,b) for(int i=1;i<=(b);i++)



#define MOD 1000000007

#define PI acos(-1)

#define ll long long int

typedef pair<int,int> pii;

typedef pair<ll, ll> pll;

#define pb push_back

#define F first

#define S second

#define sz size()

#define LCM(a,b) (a*(b/__gcd(a,b)))

//#define harmonic(n) 0.57721566490153286060651209+log(n)+1.0/(2*n)

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

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

#define MEM(a, b) memset(a, b, sizeof(a))



#define fastio ios_base::sync_with_stdio(false)



/*

#include <ext/pb_ds/assoc_container.hpp> // Common file

#include <ext/pb_ds/tree_policy.hpp> // Including */



//using namespace __gnu_pbds;

/*

template<typename T>

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

template<typename F, typename S>

using ordered_map = tree<F, S, less<F>, rb_tree_tag, tree_order_statistics_node_update>;



// find_by_order(k) – ফাংশনটি kth ordered element এর একটা পয়েন্টার রিটার্ন করে। অর্থাৎ তুমি চাইলেই kth ইন্ডেক্সে কি আছে, সেটা জেনে ফেলতে পারছো!

// order_of_key(x) – ফ࿠Ƃশনটি x এলিমਠƨ্টটޠকোন পজিশনে আছে সেটা বলে দেয়।



*/



///Inline functions



inline bool EQ(double a, double b)

{

    return fabs(a-b) < 1e-9;

}

inline bool isLeapYear(ll year)

{

    return (year%400==0) | (year%4==0 && year%100!=0);

}

inline void normal(ll &a)

{

    a %= MOD;

    (a < 0) && (a += MOD);

}

inline ll modMul(ll a, ll b)

{

    a %= MOD, b %= MOD;

    normal(a), normal(b);

    return (a*b)%MOD;

}

inline ll modAdd(ll a, ll b)

{

    a %= MOD, b %= MOD;

    normal(a), normal(b);

    return (a+b)%MOD;

}

inline ll modSub(ll a, ll b)

{

    a %= MOD, b %= MOD;

    normal(a), normal(b);

    a -= b;

    normal(a);

    return a;

}

inline ll modPow(ll b, ll p)

{

    ll r = 1;

    while(p)

    {

        if(p&1)

            r = modMul(r, b);

        b = modMul(b, b);

        p >>= 1;

    }

    return r;

}

inline ll modInverse(ll a)

{

    return modPow(a, MOD-2);

}

inline ll modDiv(ll a, ll b)

{

    return modMul(a, modInverse(b));

}

inline bool isInside(pii p,ll n,ll m)

{

    return (p.first>=0&&p.first<n&&p.second>=0&&p.second<m);

}

inline bool isInside(pii p,ll n)

{

    return (p.first>=0&&p.first<n&&p.second>=0&&p.second<n);

}

inline bool isSquare(ll x)

{

    ll s = sqrt(x);

    return (s*s==x);

}

inline bool isFib(ll x)

{

    return isSquare(5*x*x+4)|| isSquare(5*x*x-4);

}

inline bool isPowerOfTwo(ll x)

{

    return ((1LL<<(ll)log2(x))==x);

}





/// DEBUG --------------------------------------------------------------------------------->>>>>>



///**

template < typename F, typename S >

ostream& operator << ( ostream& os, const pair< F, S > & p )

{

    return os << "(" << p.first << ", " << p.second << ")";

}



template < typename T >

ostream &operator << ( ostream & os, const vector< T > &v )

{

    os << "{";

    for (auto it = v.begin(); it != v.end(); ++it)

    {

        if ( it != v.begin() )

            os << ", ";

        os << *it;

    }

    return os << "}";

}



template < typename T >

ostream &operator << ( ostream & os, const set< T > &v )

{

    os << "[";

    for (auto it = v.begin(); it != v.end(); ++it)

    {

        if ( it != v.begin())

            os << ", ";

        os << *it;

    }

    return os << "]";

}



template < typename F, typename S >

ostream &operator << ( ostream & os, const map< F, S > &v )

{

    os << "[";

    for (auto it = v.begin(); it != v.end(); ++it)

    {

        if ( it != v.begin() )

            os << ", ";

        os << it -> first << " = " << it -> second ;

    }

    return os << "]";

}



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)



clock_t tStart = clock();

#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)



void faltu ()

{

    cerr << endl;

}



template <typename T>

void faltu( T a[], int n )

{

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

        cerr << a[i] << ' ';

    cerr << endl;

}



template <typename T, typename ... hello>

void faltu( T arg, const hello &... rest)

{

    cerr << arg << ' ';

    faltu(rest...);

}



/// TEMPLATE ----------------------------------------------------------------------->>>>>>





struct func

{

//this is a sample overloading function for sorting stl

    bool operator()(pii const &a, pii const &b)

    {

        if(a.F==b.F)

            return (a.S<b.S);

        return (a.F<b.F);

    }

};

/*------------------------------Graph Moves----------------------------*/

//Rotation: S -> E -> N -> W

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

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

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

/*---------------------------------------------------------------------*/



/// Bit Operations

/// count set bit C = (num * 0x200040008001ULL & 0x111111111111111ULL) % 0xf; /// 32 bit integer

/// inline bool checkBit(ll n, int i) { return n&(1LL<<i); }

/// inline ll setBit(ll n, int i) { return n|(1LL<<i); }

/// inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }





/// ************************************** Code starts here ****************************************** */



const ll INF = 0x3f3f3f3f3f3f3f3f;

const long double EPS = 1e-9;

const int inf = 0x3f3f3f3f;

const int mx = (int)1e5+9;



ll n,m,a,b,t,i,j,d,cs=0,counT=0,k,ans=0,l=0,sum1=0,sum=0,Max,Min,num;

vector<ll>vc;

ll dp[mx];

ll DP()

{

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

    {

            if(i+1<n)

                dp[i+1] = min(abs(vc[i]-vc[i+1])+dp[i],dp[i+1]);

            if(i+2<n)

                dp[i+2] = min(abs(vc[i]-vc[i+2])+dp[i],dp[i+2]);

   //     dbg(i,dp[i+1],dp[i+2]);

    }

    return dp[n-1];

}

int main()

{

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

    fastio;

    cin >> n ;

    f0(i,n)

    {

        cin >> a ;

        vc.pb(a);

    }

    MEM(dp,63);

    dp[0] = 0 ;

    //  dbg(dp[0],dp[1]);

    cout << DP() << ln ;











    /// Comment the debugger section

}






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

using namespace std;



typedef long double LD;

typedef long long ll;

typedef map<int,int> mii;

typedef pair<int,int> pii;

typedef vector<pii> vpii;



#define pb              push_back

#define mp              make_pair

#define F               first

#define S               second

#define mod             1000000007

#define INF             2147483647

#define Endl            "\n"

#define FasterIO        ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;

#define precision(a)    cout << fixed << setprecision(a)

#define bug(a,b)        cout<<a<<"\t"<<b<<"\n";

#define Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";

#define reset(a,b)      memset(a,b,sizeof(a));

#define srt(a)      sort(a.begin(),a.end());



const int MAXN = 1000005;

const int SQRTN = 1003;

const int LOGN = 22;

const double PI=acos(-1);

const int sz=1e5+9;



int strtoint(string str){

    stringstream ss(str);

    int x = 0;

    ss >> x ;

    return x ;

}

string intostr(int x){

    stringstream ss;

    ss << x;

    string str = ss.str();

    return str;

}

void rem(string &s, const string &c) {

	auto pos = s.find(c);

	if (pos == string::npos) {

		cout << -1 << endl;

		exit(0);

	}

	s.erase(0, pos + 1);

}

void println (int n){

    cout<<n<<"\n";

}

void printvec(vector <int> &a){

    for (int i=0;i<a.size();i++){

        cout<<a[i]<<" ";

    }

    cout<<"\n";

}



void printgraph(vector <int> g[],int e){

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

        cout<<i<<" --> ";

        for (int j=0;j<g[i].size();j++){

            cout<<g[i][j]<<" ";

        }

        cout<<"\n";

    }

}



void printmap (map <int,int> &mymap){

    for (auto itr = mymap.begin(); itr != mymap.end(); ++itr) {

        cout << '\t' << itr->first

             << '\t' << itr->second << '\n';

    }

    cout << "\n";

}



int n,x,arr[sz],dp[sz];





int rec (int i){

    if (i==n) return 0;

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

    int left = abs(arr[i]-arr[i+1])+rec(i+1);

    int right = INF;

    if (i+2<=n){

        right = abs(arr[i]-arr[i+2])+rec (i+2);

    }

    return dp[i]= min(left,right);

}





void solve(){



    cin>>n;

    reset (dp,-1);

    for (int i=1;i<=n;i++)cin>>arr[i];





    cout << rec (1) << Endl;



    //printvec(v);

}





int main(){

    //FasterIO;



    solve();

    return 0;

}