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

#include <ext/numeric>



using namespace std;

using namespace __gnu_cxx;



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

#define endl "\n"

#define pb push_back

#define F first

#define S second

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

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMN INT_MIN

#define IMX INT_MAX

#define pow(n, m) power((ll)n, (ll)m)

#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)

#define mem(x, val)    memset(x, val, sizeof(x))



typedef long long ll;

typedef long double ld;

typedef double dd;

typedef string str;

typedef pair<int, int> pii;





vector<int> v;

int dp[(int)1e5];

int n;

int jump(int i){

    if(i==n-1) return 0;

    if(i>=n) return 1e9;



    int &ret = dp[i];



    if(~ret) return ret;



    int cnt = 0;

    if(i+1<n) cnt = abs(v[i] - v[i+1]) + jump(i+1);

    if(i+2<n) cnt = min(cnt, abs(v[i] - v[i+2]) + jump(i+2));



    return ret = cnt;

}

int main()

{

    THINK_TWICE_CODE_ONCE

    //freopen("test cases\\.txt", "r", stdin) ;

    cin>>n;

    v.resize(n);

    for(int &i: v) cin>>i;

    mem(dp, -1);

    cout<<jump(0);

    return 0;

}










// Faster C++ solution for the same problem (measured speedup: 1.4116345137600463x):




/******************************************************/

/******************************************************/

/**                                                  **/

/**            BISMILLAHIR RAHMANIR RAHIM            **/

/**         REAZ AHAMMED CHOWDHURY - reaziii         **/

/**  Department of Computer Science and Engineering  **/

/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/

/**                                                  **/

/******************************************************/

/******************************************************/







#include<bits/stdc++.h>

#define sc(x)        scanf("%lld",&x)

#define pcase(x)     printf("Case %d: ",x++)

#define pn           printf("\n")

#define fri(f)       for(int i=0;i<f;i++)

#define frj(f)       for(int j=0;j<f;j++)

#define reset(x,e)   memset(x,e,sizeof(x))

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

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

#define output       freopen("output.txt","w",stdout)

#define infi         INT_MAX

#define m_v          3000000

#define pii          pair<int,int>

#define pch          pair<char,char>

#define pll          pair<ll,ll>

#define mgraph       map<int,vector<int> >

#define mp           make_pair

#define pb           push_back

#define clr(x)       memset(x,0,sizeof(x))

#define frx(x,y)     for(int x=0;x<y;x++)

#define ff           first

#define ss           second

using namespace std;

typedef long long int ll;

typedef unsigned long long int ull;

bool checkbitt(ll num, int pos);

ll setbitt(ll num, ll pos);

ll resetbitt(ll num, int pos);

void read(int *aa, int sz) {fri(sz) scanf("%d", (aa + i));}

void read(ll *aa, int sz) {fri(sz) scanf("%lld", (aa + i));}

void read(ll *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%lld", (aa + i));}

void read(int *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%d", (aa + i));}

const ll mod =       1e9 + 7;

const ll N =     1e6 + 10;



//.................___Start from here___.................//

//.................._____________________................//





int solve() {

	int n;

	cin >> n;

	int arr[n + 1];

	read(arr, 1, n);



	int dp[n + 100];

	clr(dp);



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

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

		int op2 = infi;



		if (i <= n - 2) {

			op2 = abs(arr[i] - arr[i + 2]) + dp[i + 2];

		}

		dp[i] = min(op1, op2);

	}



	cout << dp[1] << endl;





	return 0;

}

int main() {

// #ifndef ONLINE_JUDGE

// 	input;

// 	output;

// #endif

// #ifdef ONLINE_JUDGE

// 	ios_base::sync_with_stdio(false);

// 	cin.tie(0);

// #endif

	int cs = 1;

	int cn = 1;

	//cin>>cs;

	while (cs--) {

		solve();



	}

}





bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}

ll setbitt(ll num, ll pos) {return (1 << pos) | num;}

ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}