// Original C++ solution (slower):
/**

 *   created: 25 January 2019  00:27:23

**/

#include<bits/stdc++.h>

using namespace std;



typedef vector<int> vi;

typedef pair<int , int> pii;

typedef vector< pair<int , int> > vii;

typedef long long ll;

typedef vector<long long> vl;

typedef pair<long long , long long> pll;

typedef vector< pair<long long , long long> > vll;



#define PB push_back

#define PPB pop_back

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

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

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

#define INFLL 2000000000000000007

#define INF 2000000007

#define MOD 1000000007



void optimizeIO()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

}



//                                        //AUTHOR: Kaushalesh Shukla



//=========================================================================================================

vector<int> dp(100000,-1),v(100000);

int n;

int frog(int cs)

{

	if(cs<=0)

		return 0;

	if(cs==1)

		return abs(v[cs]-v[0]);

	if(dp[cs]!=-1)

		return dp[cs];

	return dp[cs]=min((abs(v[cs]-v[cs-1])+frog(cs-1)), (abs(v[cs]-v[cs-2])+frog(cs-2)));



}

int main()

{

	optimizeIO();

	cin>>n;

	// v.resize(n);

	// dp.resize(n);

	F(i,0,n-1)

		cin>>v[i];

	cout<<frog(n-1);

	return 0;

}


// Optimized solution to the same problem (faster):
/**

 *   created: 20 August 2019  11:36:13

**/

#include<bits/stdc++.h>

using namespace std;



typedef vector<int> vi;

typedef pair<int , int> pii;

typedef vector< pair<int , int> > vii;

typedef long long ll;

typedef vector<long long> vl;

typedef pair<long long , long long> pll;

typedef vector< pair<long long , long long> > vll;



#define PB push_back

#define PPB pop_back

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

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

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

#define INFLL 2000000000000000007

#define INF 2000000007

#define MOD 1000000007





#define TRACE



#ifdef TRACE

#define trace1(x)                cerr << #x << ": " << x << endl;

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

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

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

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

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



#else



#define trace1(x)

#define trace2(x, y)

#define trace3(x, y, z)

#define trace4(a, b, c, d)

#define trace5(a, b, c, d, e)

#define trace6(a, b, c, d, e, f)



#endif





void optimizeIO()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

}



//                                        //AUTHOR: Kaushalesh Shukla



//=========================================================================================================



int main()

{

	optimizeIO();

	int tt=1;

	//cin>>tt;

	while(tt--){

		int n;

		cin>>n;

		vi h(n);

		rep(i,0,n)

			cin>>h[i];

		vi mem(n);

		mem[0] = 0;

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

		rep(i,2,n){

			mem[i] = min(mem[i-2]+abs(h[i-2]-h[i]),mem[i-1]+abs(h[i-1]-h[i]));

		}

		cout<<mem[n-1];

	}

	return 0;

}


// Fastest known solution for this problem: