// Slower C++ solution:
#define __USE_MINGW_ANSI_STDIO

#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include <unordered_set>

#include <unordered_map>



using namespace std;



typedef long long ll;

typedef long long ull;

typedef pair<ll, ll> ii;



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

#define sz(v)		((int)((v).size()))

#define endl		"\n"

#define fx(n)		fixed<<setprecision(n)

#define mk			make_pair	



void File()

{

#ifndef ONLINE_JUDGE

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

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

#endif

#ifdef ONLINE_JUDGE

	/*freopen("output.txt", "w", stdout);

	freopen("pyramid.in", "r", stdin);*/

#endif

}

void fast()

{

	ios::sync_with_stdio(NULL);

	cout.tie(NULL);

	cin.tie(NULL);

	//File();

}

const double pi = 2 * acos(0.0);

const ll oo = 0x3f3f3f3f;

const int MOD = 1e9 + 7;

const int nn = 1e5 + 15;

int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };



int n;

ll arr[nn];

ll dp[nn];

int main()

{

	fast();

	cin >> n;

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

		cin >> arr[i];

	memset(dp, oo, sizeof dp);

	dp[0] = 0;

	for (int i = 1; i < n; i++)

	{

		if (i == 1)

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

		else

			dp[i] = min({ dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]) });

	}

	cout << dp[n - 1] << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.781496022010378x):
#include <iostream>

#include <string>

#include<iomanip>

#include <algorithm>

#include <map>

#include <vector>

#include<queue>

#include<math.h>

#include<cmath>

#include<sstream>

#include<set>

#include <map>

#include<string.h>

#include<sstream>

#include<stack>

#include<unordered_map>

#include <iostream>

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

#include <cstdio>

#include <cstdlib>

#include <complex>

#define ll long long

#define  point complex<double>

#define  pi acos(-1)

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define arr2dof vector  vector<vector<int>>dp(N,vector<int>(2, inf));

using namespace std;

const ll N = 2e5 + 5, mod = 1e9 + 7, inff = -1e12,inf=1e12;

const double ep = 0.0000000001;

//const double pi = 3.14159265359;



double dot(point a, point b) {

	return  (conj(a)*b).real();

}

double cross(point a, point b) {

	return  (conj(a)*b).imag();

}

double angle(point a, point b)

{

	double dt = dot(a, b);

	dt /= abs(a);

	dt /= abs(b);

	return acos(dt) * 180.0 / pi;

}



bool isrightangel(int ind) {//90 degree

	vector<point>v;

	return(angle(v[ind] - v[(ind + 1) % 3], v[ind] - v[(ind + 2) % 3]) == 90);//bshof hal eldot producty3ny fe

	//dl3en 3moden 3ashn yb2a right trinagle

}



ll fact[1000006], inv[1000006];



ll fp(ll base, ll exp)

{

	if (exp == 0)

		return 1;

	ll ans = fp(base, exp / 2);

	ans = (ans * ans) % mod;

	if (exp % 2 != 0)

		ans = (ans * (base % mod)) % mod;

	return ans;

}



void calcFacAndInv(ll n)

{

	fact[0] = inv[0] = 1;

	for (ll i = 1; i <= n; i++)

	{

		fact[i] = (i * fact[i - 1]) % mod;

		inv[i] = fp(fact[i], mod - 2);

	}

}



ll ncr(ll n, ll r)

{

	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;

}



ll npr(ll n, ll r)

{

	return (fact[n] * inv[n - r]) % mod;

}











	int dp[N];

int main()

{

	ll n,arr[100005];

	cin >> n;

	for (int i = 0; i < n; ++i) {

		cin >> arr[i];

	}

	dp[0] = 0;//land on 1

	dp[1] = abs(arr[0]-arr[1]);//to land on 2

	for (int i = 2; i < n; ++i) {

		dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);

	}

	cout << dp[n - 1];

	return 0;

}