// Slower C++ solution:
/*

				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "

*/





#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#define f for

#define ll long long

#define ull unsigned long long

#define endl "\n"

using namespace std;

#define BI  acos(-1)

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

void Open()

{

#ifndef ONLINE_JUDGE

	freopen("Input.txt", "r", stdin);

	freopen("Output.txt", "w", stdout);

#endif

}

ll gcd(ll a, ll b)

{

	return b == 0 ? a : gcd(b, a % b);

}

void madesetprobblem()

{

	//$ $

	//less than or equal => $ 1 \leq 100 $

	//  $(1 \le A,B \le 10^5 )$

	// a[i] => $a_i$

	// a[i][j] => $a_{i,j}$

	// double qoutes ''yext''

	/*

		image

		\begine{center}

		\includegraphics{image.jpg}

		\end{center}

	*/

	/*

		list

		\begin{itemize}

			\item first one

			\item second one

		\end{itemize}

	*/

}

int n;

vector<int>a(1e5 + 2),dp(1e5+2,-1);

int ans(int c = 0)

{

	if (c == n-1)

		return 0;

	int ans1 = INT_MAX, ans2 = INT_MAX;

	if (dp[c] != -1)

		ans1 = dp[c];

	else

	{

		if (c + 1 < n)

			ans1 = (abs(a[c] - a[c + 1]) + ans(c + 1));

		if (c + 2 < n)

			ans2 = (abs(a[c] - a[c + 2]) + ans(c + 2));

		dp[c] = min(ans1, ans2);

	}

	//cout <<c<<" "<< ans1 << " " << ans2 << endl;

	return min(ans1,ans2);

}

int main()

{

	// توكلت علي الله 

//Open();

	ios::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	cin >> n;

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

	{

		cin >> a[i];

	}

	cout << ans();

}

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




/******************************************************/

/******************************************************/

/**                                                  **/

/**            BISMILLAHIR RAHMANIR RAHIM            **/

/**         REAZ AHAMMED CHOWDHURY - reaziii         **/

/**  Department of Computer Science and Engineering  **/

/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/

/**                                                  **/

/******************************************************/

/******************************************************/







#include<bits/stdc++.h>

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

#define pcase(x)     printf("Case %d: ",x++)

#define pn           printf("\n")

#define fri(f)       for(int i=0;i<f;i++)

#define frj(f)       for(int j=0;j<f;j++)

#define reset(x,e)   memset(x,e,sizeof(x))

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

#define input        freopen("input.txt","r",stdin);

#define output       freopen("output.txt","w",stdout)

#define infi         INT_MAX

#define m_v          3000000

#define pii          pair<int,int>

#define pch          pair<char,char>

#define pll          pair<ll,ll>

#define mgraph       map<int,vector<int> >

#define mp           make_pair

#define pb           push_back

#define clr(x)       memset(x,0,sizeof(x))

#define frx(x,y)     for(int x=0;x<y;x++)

#define ff           first

#define ss           second

using namespace std;

typedef long long int ll;

typedef unsigned long long int ull;

bool checkbitt(ll num, int pos);

ll setbitt(ll num, ll pos);

ll resetbitt(ll num, int pos);

void read(int *aa, int sz) {fri(sz) scanf("%d", (aa + i));}

void read(ll *aa, int sz) {fri(sz) scanf("%lld", (aa + i));}

void read(ll *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%lld", (aa + i));}

void read(int *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%d", (aa + i));}

const ll mod =       1e9 + 7;

const ll N =     1e6 + 10;



//.................___Start from here___.................//

//.................._____________________................//





int solve() {

	int n;

	cin >> n;

	int arr[n + 1];

	read(arr, 1, n);



	int dp[n + 100];

	clr(dp);



	for (int i = n - 1; i >= 1; i--) {

		int op1 = abs(arr[i] - arr[i + 1]) + dp[i + 1];

		int op2 = infi;



		if (i <= n - 2) {

			op2 = abs(arr[i] - arr[i + 2]) + dp[i + 2];

		}

		dp[i] = min(op1, op2);

	}



	cout << dp[1] << endl;





	return 0;

}

int main() {

// #ifndef ONLINE_JUDGE

// 	input;

// 	output;

// #endif

// #ifdef ONLINE_JUDGE

// 	ios_base::sync_with_stdio(false);

// 	cin.tie(0);

// #endif

	int cs = 1;

	int cn = 1;

	//cin>>cs;

	while (cs--) {

		solve();



	}

}





bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}

ll setbitt(ll num, ll pos) {return (1 << pos) | num;}

ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}