// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define ld long double

#define sf scanf

#define pf printf

#define pb push_back

#define llu unsigned long long

#define U unsigned int

#define SIZE 1000002

#define pie 3.14159265358979323

#define minuss 1e-6

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

 

#define BIG 100000000

 

ll  lcm(ll a,ll b)

{

    ll GCD=__gcd(a,b);

    ll lcm=(a*b)/GCD;

    return lcm;

}

ll dp[100005];

ll weight[1000005],value[1000005];

ll total,val;

ll call(ll n)

{

    if(n>=total)

        return 0;

 

    if(dp[n]!=-1)

        return dp[n];

 

    ll res1=BIG,res2=BIG;

 

   // if(weight[n]+c<=val)

    res1=abs(weight[n]-weight[n+1]) + call(n+1);

    if(n+2<=total) res2=abs(weight[n]-weight[n+2]) + call(n+2);

    //cout<<n<<" "<<res1<<" "<<res2<<endl;

    dp[n]=min(res1,res2);

    return dp[n];

 

}

int main()

{

    cin>>total;

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

        cin>>weight[i];

 

    memset(dp, -1, sizeof(dp));

    ll ret=call(1);

    cout<<ret<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7812793043118194x):
#include <bits/stdc++.h>



#define ll long long

#define ld long double

#define ull unsigned long long

#define endl "\n"

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

#define f(a, b, c) for(int a = b; a < c; a++)

using namespace std;

const ll mod = 1e9 + 7;







//ll fact[1000001]; ll inv[1000001];

//ll primes[100007];

//ll arr[1000007];

//ll modPower(ll b, ll p) {

//	if (p == 0)

//		return 1;

//

//	ll halfpow = modPower(b, p / 2);

//	ll toReturn = (halfpow * halfpow) % mod;

//	if (p % 2)

//		toReturn = (toReturn * b) % mod;

//

//	return toReturn;

//}

//

//ll fastPower(ll b, ll p) {

//	if (p == 0)

//		return 1;

//	ll ans = fastPower(b, p / 2);

//	ans = (ans * ans);

//	if (p % 2 != 0)

//		ans = (ans * b);

//	return ans;

//}

//ll GcdRecursive(ll a, ll b) {

//	if (b == 0) return a;

//	return GcdRecursive(b, a % b);

//}

//ll modLCM(ll a, ll b) {

//	ll val = GcdRecursive(a, b);

//	ll tmp = ((a % mod) * (b % mod)) % mod;

//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;

//	return finalVal;

//

//}

//ll LCM(ll a, ll b) {

//	return (a * b) / GcdRecursive(a, b);

//}

//void move1step(ll& a, ll& b, ll q) { // a and b by reference

//	ll c = a - q * b;

//	a = b;

//	b = c;

//}

//ll GcdIterative(ll a, ll b) {

//	while (b) move1step(a, b, a / b);

//	return a;

//}

//

//void pre(ll n) {

//

//	fact[0] = 1;

//	inv[0] = 1;

//

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

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

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

//		arr[i] = modPower(i, mod - 2);

//	}

//}

//

//ll npr(ll n, ll r) {

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

//}

//

//ll ncr(ll n, ll r) {

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

//}

//

//void sieve(ll val) {

//	memset(primes, 1, sizeof primes);

//	primes[0] = primes[1] = false;

//	for (int i = 2; i <= val; i++) {

//		if (primes[i]) {

//			for (int j = i * i; j <= val; j += i) {

//				primes[j] = 0;

//			}

//		}

//	}

//

//}





const ll N = 1e5 + 7;



ll x;

ll a[N] = {};

ll dp[N] = {};



int main()

{

    MohamedMotaz;

    

    cin >> x;



    f(i, 0, x) cin >> a[i];

    dp[0] = 0;

    dp[1] = abs(a[1] - a[0]);

    f(i, 2, x) dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));

    cout << dp[x - 1];



   



}