// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long int

#define dbl double

#define pi acos(-1)

#define sc1(a) scanf("%lld",&a)

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

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

#define pb push_back



ll ara[1000005];



map<ll,ll>vis;

map<ll,ll>vis1;

map<ll,ll>pos;

map<ll,ll>high;

map<ll,ll>low;

map<string,ll>mp;

vector<ll>vec;

vector<ll>v;

stack<ll>q;

string str1[100];

string str2[100];

priority_queue<ll>pq;

ll dp[1000005],t;

ll mn=1000000;

ll call(ll id)

{

    if(id==t )return 0;

    if(dp[id]!=-1)

        return dp[id];

    ll p=call(id+1)+abs(ara[id+1]-ara[id]);

    ll q=100000000;

    if(id+2!=t+1)

        q=call(id+2)+abs(ara[id+2]-ara[id]);

    dp[id]=min(p,q);

    return dp[id];



}

int main()

{



    // ll t;

    memset(dp,-1,sizeof(dp));

    sc1(t);

    for(ll i=1; i<=t; i++)

    {

        sc1(ara[i]);

    }

    cout<<call(1)<<endl;

    return 0;

}


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

     

    using namespace std;

     

    void __print(int x) {

        cerr << x;

    }

    void __print(long x) {

       cerr << x;

    }

    void __print(long long x) {

       cerr << x;

    }

    void __print(unsigned x) {

        cerr << x;

    }

    void __print(unsigned long x) {

        cerr << x;

    }

    void __print(unsigned long long x) {

        cerr << x;

    }

    void __print(float x) {

        cerr << x;

    }

    void __print(double x) {

        cerr << x;

    }

    void __print(long double x) {

        cerr << x;

    }

    void __print(char x) {

        cerr << '\'' << x << '\'';

    }

    void __print(const char *x) {

        cerr << '\"' << x << '\"';

    }

    void __print(const string &x) {

        cerr << '\"' << x << '\"';

    }

    void __print(bool x) {

        cerr << (x ? "true" : "false");

    }

     

    template<typename T, typename V>

    void __print(const pair<T, V> &x) {

        cerr << '{'; 

        __print(x.first); cerr << ','; 

       __print(x.second); cerr << '}';

    }

    template<typename T>

    void __print(const T &x) {

        int f = 0; cerr << '{'; 

        for (auto &i: x) 

            cerr << (f++ ? "," : ""), __print(i); 

        cerr << "}";

    }

    void _print() {

        cerr << "]\n";

    }

    template <typename T, typename... V>

    void _print(T t, V... v) {

        __print(t); 

        if (sizeof...(v)) 

            cerr << ", "; _print(v...);

    }

     

    #ifndef ONLINE_JUDGE

    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

    #else

    #define debug(x...)

    #endif

     

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

    #define forw(i, w) for(int i = n; i >= 0; i--)

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

    #define dforw(i, b, a) for(int i = b; i >= a; i--)

    #define read(v) for(auto &i:v) cin >> i;

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

     

    typedef long long ll;

    typedef vector<int> vi;

    typedef vector<double> vd;

    typedef pair<int, int> pii;

     

    int n, k;

    vi arr, dp;

     

    int main(){

    	ios_base::sync_with_stdio(0);

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

    	

    	cin >> n;

    	k=2;

    	arr.assign(n, 0);

    	dp.assign(n, 999999999);

    	dp[0] = 0;

    	read(arr);

     

    	forn(i, n)

    		for(int j = i+1; j < n && j < i+k+1; j++)

    			dp[j] = min(dp[j], dp[i]+abs(arr[j]-arr[i]));

     

    	cout << dp[n-1] << endl;	

    	return 0;

    }