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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

using namespace std;

#define DEBUG

#ifdef DEBUG

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

	template <typename Arg1>

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

		cerr << name << " : " << arg1 << std::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...);

	}

#else

#define debug(...)

#endif

#define FOR(i,a,b) 	for(int i=a;i<b;++i)

#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)

#define ln 		"\n"

#define mp make_pair

#define pb push_back

#define sz(a)	ll(a.size())

#define F first

#define S second

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

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

#define trace(c,x) for(auto &x:c)

#define pii pair<ll,ll>

#define init(a, x) memset(a,x,sizeof(a))

typedef long long ll;

typedef long double ld;

typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// ordered_set X

//K-th smallest

//*X.find_by_order(k-1)

//NO OF ELEMENTS < A

//X.order_of_key(A)

const int L=1e6+7;

ll n, h[L], dp[L];

ll solve(int i)

{

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

	if(i>=n)return INT_MAX;

	if(dp[i] != -1)return dp[i];

	ll &ret = dp[i];

	ret = INT_MAX;

	ret = solve(i+1) + abs(h[i]-h[i+1]);

	ret = min(ret,solve(i+2) + abs(h[i]-h[i+2]));

	return ret;

}

void fff()

{

	cin >> n;

	init(dp, -1);

	FOR(i,0,n)cin >> h[i];

	cout<<solve(0)<<ln;

}

int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	//int t;cin >> t;while(t--)

	fff();

	return 0;

}

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

#include<iomanip>

#include<cstdio>

#include<cmath>

#include<vector>

#include<string>

#include<algorithm>

#include<queue>

#include<set>

#include<map>

#include<limits>

#include<stack>



using namespace std;



typedef unsigned long long ll;

typedef pair<int,int> ii;

typedef vector<pair<int,int> > vii;

typedef vector<vii> vvii;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef vector<ll> vll;

typedef vector<vll> vvll;

typedef vector<bool> vb;

typedef vector<vb> vvb;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<string> vs;



int INF = std::numeric_limits<int>::max();

int NINF = std::numeric_limits<int>::min();

int MOD = 1e9+7;



int col[] = {0,-1,0,1,1,1,-1,-1};

int row[] = {-1,0,1,0,1,-1,1,-1};



//knight moves

int cc[] = {1,2,2,1,-1,-1,-2,-2};

int rr[] = {-2,-1,1,2,-2,2,1,-1};



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int n;

    cin >> n;



    vi hight(n);

    vll cost(n);



    cin >> hight[0];

    cost[0] = 0;



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

    {

        cin >> hight[i];



        if(i > 1)

        {

            ll one = abs(hight[i]-hight[i-1]), two = abs(hight[i]-hight[i-2]);



            cost[i] = min(one+cost[i-1],two+cost[i-2]);



            //cout << i << " " << cost[i] << endl;

        }

        else

        {

            cost[i] = abs(hight[0]-hight[1]);

        }

    }



    cout << cost[n-1];



    return 0;

}