#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

const int N = 1e5;

int dp[N+5];
int arr[N+5];

int main(){

	ios_base::sync_with_stdio(0);
	int n; cin >>n;
	for(int i = 1; i<=n; i++) cin >>arr[i];
	
	dp[0] = dp[1] = 0;
		
	for(int i = 2; i<=n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i]), dp[i-2] + abs(arr[i-2] - arr[i])); 
	}
	
	cout <<dp[n] <<endl;
	return 0;
}