#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
*void exEuclid(int a, int b){
	if(b==0){x = 1; y=0; d=a; return ;}
	exEuclid(b, a%b);
	int x1=y;
	int y1=x-(a/b)*y;
	x=x1;
	y=y1;
} 
* */
//===========================================================//
const int nax = 1e5+3;
int n;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
	return dp[i]=ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}