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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f

#define INF 0x3f3f3f3f

#define pb push_back

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

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

#define for0(i, n) for(int i = 0; i < n; ++i)

#define for1(i, n) for(int i = 1; i <= n; ++i)

using namespace std;

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<long long, int> pli;

typedef pair<long long, long long> pll;

const int mod = 1e9 + 7;

const int N = 1e5+10;

const int M = 1e6+10;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}

inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}

//==================================================================================================================================================================//



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



int main() {

   scanf("%d", &n);

   ms(dp, inf); dp[n] = 0;

   for1(i, n) scanf("%d", h+i);

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

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

      else {

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

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

      }

   }

   printf("%d\n", dp[1]);

   return 0;

}