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

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

#define ii          pair<int,int>

#define F           first

#define S           second

#define pb          push_back

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

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

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

#define forr(i,a)   for(int i = a; i >= 0; i--)

#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 

#define w(t)        while(t--)

#define sz(s)       int(s.size())

#define cls(a,car)  memset(a,car,sizeof (a))

#define db(x)       cerr << #x << " is " << x << '\n'

#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);

#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

#define angle(x)    double(x * acos(-1) / 180.0)

using namespace std;

typedef long long   ll;

typedef vector<int> vi;

typedef vector<ii>  vii;

const int N = 1 * 1e5 + 5;

const ll mod = 1e9 + 7;

const double E = 1e-9;

//int dx[] = {1, 0}, dy[] = {0, 1};

//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};

//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};

// fflush(stdout)

// cout << flush

// a + b = a ^ b + 2 * (a & b)

int v[N];

int dp[N];

int n, k = 2;

int f(int i){

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

    int &ans = dp[i];

    if(ans == -1){

        ans = 1e9;

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

            if(i + j < n)

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

            else

                break;

    }

    return ans;

}

int main(){

    //FL;

    FIN;

    cin >> n;

    fore(i, 0, n)cin >> v[i];

    cls(dp, -1);

    cout << f(0) << '\n';

    

    EjecuteTime;

    return 0;

}       

// Faster C++ solution for the same problem (measured speedup: 1.4091441805838836x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

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 ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



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



	dp[n] = 0;



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

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



}