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

#define LOCAL

using namespace std;

template <typename A, typename B>

ostream& operator <<(ostream& out, const pair<A, B>& a) {

out << "(" << a.first << "," << a.second << ")";

return out;

}

template <typename T, size_t N>

ostream& operator <<(ostream& out, const array<T, N>& a) {

out << "["; bool first = true;

for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";

return out;

}

template <typename T>

ostream& operator <<(ostream& out, const vector<T>& a) {

out << "["; bool first = true;

for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";

return out;

}

template <typename T, class Cmp>

ostream& operator <<(ostream& out, const set<T, Cmp>& a) {

out << "{"; bool first = true;

for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";

return out;

}

template <typename U, typename T, class Cmp>

ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {

out << "{"; bool first = true;

for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";

return out;

}

#ifdef LOCAL

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

#else

#define trace(...) 42

#endif

template <typename Arg1>

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

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

}

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

using ll = long long;

#define int long long

using P = pair<int,int>;

//#########################################

int n,a[110000];

const int INF = 1001001001;

int dp[110000];

int dfs(int x){

	//1 kara x

	if(x == 1)return 0;

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

	int ret = INF;

	if(x-1 >= 1)ret = min(ret,dfs(x-1) + abs(a[x] - a[x-1]));

	if(x-2 >= 1)ret = min(ret,dfs(x-2) + abs(a[x] - a[x-2]));

	return dp[x] = ret;

}

signed main(){

	cin >> n;

	rep(i,n)cin >> a[i+1];

	rep(i,110000)dp[i] = -1;

	cout <<dfs(n) << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8660769644787745x):
#include <bits/stdc++.h>

#define LOCAL

using namespace std;

template <typename A, typename B>

ostream& operator <<(ostream& out, const pair<A, B>& a) {

out << "(" << a.first << "," << a.second << ")";

return out;

}

template <typename T, size_t N>

ostream& operator <<(ostream& out, const array<T, N>& a) {

out << "["; bool first = true;

for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";

return out;

}

template <typename T>

ostream& operator <<(ostream& out, const vector<T>& a) {

out << "["; bool first = true;

for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";

return out;

}

template <typename T, class Cmp>

ostream& operator <<(ostream& out, const set<T, Cmp>& a) {

out << "{"; bool first = true;

for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";

return out;

}

template <typename U, typename T, class Cmp>

ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {

out << "{"; bool first = true;

for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";

return out;

}

#ifdef LOCAL

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

#else

#define trace(...) 42

#endif

template <typename Arg1>

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

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

}

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

using ll = long long;

#define int long long

using P = pair<int,int>;

//#########################################

const int INF = 1e18;

void chmin(int &a,int b){

    if( a > b) a = b;

}

signed main(){

    int n;cin >> n;

    vector<int> a(n);

    rep(i,n)cin >> a[i];

    vector<int> dp(n+1,INF);

    dp[1] = 0;

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

        if(i+2 < n+1)chmin(dp[i+2],dp[i] + abs(a[i+1] - a[i-1]));

        if(i+1 < n+1)chmin(dp[i+1],dp[i] + abs(a[i] - a[i-1]));

    }

    cout << dp[n] << endl;



    return 0;

}