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

using namespace std;

 

#define pb push_back

#define ff first

#define ss second

#define endl '\n'

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

const double eps = 1e-6;



/////////////////////////////////////////////



void __print(int x) {cerr << x;}

void __print(long x) {cerr << x;}

void __print(long long x) {cerr << x;}

void __print(unsigned x) {cerr << x;}

void __print(unsigned long x) {cerr << x;}

void __print(unsigned long long x) {cerr << x;}

void __print(float x) {cerr << x;}

void __print(double x) {cerr << x;}

void __print(long double x) {cerr << x;}

void __print(char x) {cerr << '\'' << x << '\'';}

void __print(const char *x) {cerr << '\"' << x << '\"';}

void __print(const string &x) {cerr << '\"' << x << '\"';}

void __print(bool x) {cerr << (x ? "true" : "false");}



template<typename T, typename V>

void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>

void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>

void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#else

#define debug(x...)

#endif



////////////////////////////////



#define int long long

const int N = 1e5 + 10;

int n;

int a[N];

int dp[N];



int calc(int pos){



    if(pos < 0)

        return 1e10;

    if(pos==0)

        return 0;



    int &ans = dp[pos];



    if(ans!=-1)

        return ans;



    ans = min(abs(a[pos] - a[pos-1]) + calc(pos-1) , abs(a[pos] - a[pos-2]) + calc(pos-2));



    return ans;





}



void solve(){



    cin>>n;

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

        cin>>a[i];



    memset(dp , -1,sizeof dp);



    int ans = calc(n-1);



    cout<<ans<<endl;

}

signed main(){



    fast;

    int t = 1;

    //cin>>t;

    while(t--)

        solve();

}


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

using namespace std;

 

#define pb push_back

#define ff first

#define ss second

#define endl '\n'

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

const double eps = 1e-6;







/////////////////////////////////////////////



void __print(int x) {cerr << x;}

void __print(long x) {cerr << x;}

void __print(long long x) {cerr << x;}

void __print(unsigned x) {cerr << x;}

void __print(unsigned long x) {cerr << x;}

void __print(unsigned long long x) {cerr << x;}

void __print(float x) {cerr << x;}

void __print(double x) {cerr << x;}

void __print(long double x) {cerr << x;}

void __print(char x) {cerr << '\'' << x << '\'';}

void __print(const char *x) {cerr << '\"' << x << '\"';}

void __print(const string &x) {cerr << '\"' << x << '\"';}

void __print(bool x) {cerr << (x ? "true" : "false");}



template<typename T, typename V>

void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>

void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>

void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#else

#define debug(x...)

#endif



////////////////////////////////



#define int long long







void solve(){



	int n;

	cin>>n;

	vector<int> a(n+2);

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

		cin>>a[i];



	int dp[n+2];



	dp[0] = 0;

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

		dp[i] = 1e12;

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



			if(i-j < 0)

				break;



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

		}

	}



	cout<<dp[n-1]<<endl; 





}

signed main(){



    fast;

    int t = 1;

    //cin>>t;

    while(t--)

        solve();

}