// 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.273713825964219x):
#include "bits/stdc++.h"



#define ll long long

#define ull unsigned long long

#define ld long double



#define tiii tuple < int, int, int >

#define pii pair < int, int >

#define pll pair < ll, ll >

#define pci pair < char, int >

#define psi pair < string, int >

#define pis pair < int, string >



#define vi vector < int >

#define vd vector < double >

#define vld vector < ld >

#define vll vector < ll >

#define vs vector < string >

#define vc vector < char >

#define vpi vector < pii >

#define vpll vector < pll >

#define vpis vector < pis >



#define pb push_back

#define mt make_tuple

#define gt0 get < 0 >

#define gt1 get < 1 >

#define gt2 get < 2 >



#define pi acos(-1)



#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)



using namespace std;



const int maxn = 1e5 + 5;

const int mod = 1e9 + 9;



ll a[maxn], f[maxn];



int main()

{

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

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



    fast;



    int n, k = 2;



    cin >> n;



    for(int i = 1; i <= n; i++) cin >> a[i];



    f[n] = 0;



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

        f[i] = 1e18;



        for(int j = 1; j <= k; j++){

            if(i + j > n) continue;



            f[i] = min(f[i], f[i + j] + abs(a[i] - a[i + j]));

        }

    }



    cout << f[1] << endl;



    return 0;

}