// Slower C++ solution:
#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;

}


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



using namespace std;



#define oo (1L<<62)

#define ll long long int



int h[100005];

ll memo[100005];

char visitado[100005];

int N;



ll memoiter[3];



ll costo(int  n){

    if(!n) return n;

    if(n == 1) return abs(h[0]-h[1]);

    if(visitado[n]) return memo[n];

    visitado[n] = 1;

    return memo[n]= min(costo(n-1)+abs(h[n]-h[n-1]), 

                    costo(n-2)+abs(h[n]-h[n-2])); 

}



ll iterativo(){

    memoiter[0] = 0;

    memoiter[1] = abs(h[0]-h[1]);

    for(int i = 2; i<N; i++)

        memoiter[i%3] = min(memoiter[(i-1)%3]+abs(h[i]-h[i-1]),

                      memoiter[(i-2)%3]+abs(h[i]-h[i-2]));

    return memoiter[(N-1)%3];

}

    



int main()

{

    cin>>N;

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

        cin>>h[i];

    cout<<costo(N-1)<<"\n";

}