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



using namespace std;

typedef long long ll;

typedef double dd;

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

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



const int N = 1e5 + 9;

int n, h[N], dp[N];



int sol(int i){

    if(i<0) return 1e9;

    if(i==0) return 0;



    if(~dp[i]) return dp[i];



    return dp[i] = min(abs(h[i]-h[i-1]) + sol(i-1), abs(h[i]-h[i-2]) + sol(i-2));

}





int main() {



    cin >> n;



    for(int i = 0;i < n;i++)    cin >> h[i];



    memset(dp, -1, sizeof dp);



    cout << sol(n - 1);

}

// Faster C++ solution for the same problem (measured speedup: 1.3787433298902247x):
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>

#include<iomanip>

#include<cmath>

#include<numeric>

#include<vector>

#include<algorithm>

#include<string>

#include<deque>

#include<stack>

#include<map>

#include<cstring>

#include<random>

#include<queue>

#include<iterator>

#include<bitset>

#include<unordered_set>

#include<set>



using namespace std;

#define ll long long

#define endl "\n"

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

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

const ll integer = pow(2, 32) - 1; // 4294967295

#define N 8010000

#define TC int t;cin>>t;for(int T=1;T<=t;T++)

#define mod 1000000007

#define PI acos(-1)

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

#define rall(x) (x).rbegin(),(x).rend()

#define clr(v, d) memset(v, d, sizeof(v)) 

void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

bool isprime(ll n) {

	for (ll i = 2; i * i <= n; i++) {

		if (n % i == 0)return 0;

	}

	return (n != 1);

}

ll gcd(ll x, ll y)

{

	return (y == 0 ? x : gcd(y, x % y));

}

ll lcm(ll x, ll y) {

	return (x * y) / gcd(x, y);

}

/*

 _____________              __                ___        ___       ___________________________     ____        ____

|             |            /\ \              |   |      |   |     |                           |    \   \      /   /

|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /

|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /

|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /

|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /

|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /

|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |

|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |

|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |

|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |

|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |

|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|



										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>

										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>

										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/

int n, x, k, m, cnt = 0;

vector<int>v1, v2, v3;

int dp[100007];

int main()

{

	//cout<<fixed<<setprecision(20);

	//freopen("Input.txt.txt", "r", stdin);

	//freopen("Output.txt.txt", "w", stdout);

	AIA();

	cin >> n;

	v1.resize(n);

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

		cin >> v1[i];

	}

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

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

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

	}

	cout << dp[n - 1];

	return 0;

}