#include <bits/stdc++.h>
using namespace std;


#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
ll mod = 1e9 + 7;
ld eps = 1e-6;




int main() {
	fastIO;
	int n;
	cin >> n;
	int dp[n+1], arr[n+1];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (i > 1) {
			dp[i] = min(abs(arr[i-1]-arr[i]) + dp[i-1], abs(arr[i-2]-arr[i]) + dp[i-2]);
		}
		else {
			dp[i] = abs(arr[i-1]-arr[i]) + dp[i-1];
		}
	}

	cout << dp[n-1];

}
