// Slower C++ solution:
/**

 *   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;

}


// Faster C++ solution for the same problem (measured speedup: 1.7832388237467711x):
/**

 *   created: 22 May 2019  22:00:21

**/

#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 rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#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 v(n);

		rep(i,0,n)

			cin>>v[i];

		vector< vi > mem(n,vi(2,0));

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

		mem[1][1] = INF;

		rep(i,2,n){

			mem[i][0] = min(mem[i-1][0],mem[i-1][1]) + abs(v[i]-v[i-1]);

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

			// trace2(mem[i][0],mem[i][1]);

		}

		cout<<min(mem[n-1][0],mem[n-1][1]);

	}

}