// Slower C++ solution:
#include<set>

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

#define debug(x) cout << #x << " = " << x << endl

#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)

#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)

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

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

const int mod = (int)1e9 + 7;

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n;

int h[maxn], dp[maxn];



int main()

{

	n = read();

	rep(i, 1, n) h[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[1] = 0;

	rep(i, 1, n){

		dp[i+1] = qmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));

		dp[i+2] = qmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));

	}

	printf("%d\n", dp[n]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3551525602864711x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1) {

	cerr << name << " : " << arg1 << endl;

}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args) {

	const char* comma = strchr(names + 1, ',');

	cerr.write(names, comma - names) << " : " << arg1 << "  ";

	__f(comma + 1, args...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

#define rep(i,n) for(int i=0;i++<n;)

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



}