#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5+5;
int a[maxn], dp[maxn];

int main(){
	int n; cin >> n;
	memset(dp, 0x3f, sizeof dp);
	for(int i = 1; i <= n; i++) cin >> a[i];
	dp[1] = 0;
	for(int i = 2; i <= n; i++){
		dp[i] = min(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
		if(i > 2) dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
	}
	cout << dp[n] << endl;
}