// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

 

#define ff              first

#define ss              second

#define int             long long

#define pb              push_back

#define mp              make_pair

#define pii             pair<int, int>

#define vi              vector<int>

#define si              set<int>

#define usi             unordered_set<int>

#define mii             map<int, int>

#define umii            unordered_map<int, int>

#define pqb             priority_queue<int>

#define pqs             priority_queue<int, vi, greater<int> >

#define setbits(x)      __builtin_popcountll(x)

#define zrobits(x)      __builtin_ctzll(x)

#define mod             1000000007

#define inf             1e18

#define endl            '\n'

#define ps(x,y)         fixed<<setprecision(y)<<x

#define mk(arr,n,type)  type *arr=new type[n];

#define w(t)            int t; cin>>t; while(t--)

mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

 

void jaiswal_sahil()

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// #ifndef ONLINE_JUDGE

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

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

// #endif

}



const int N = 1e6;

int dp[N];

int n;



int minCost(int i, int *a){



    if(i >= n-1)

        return 0;



    if(dp[i] != -1)

        return dp[i];



    int q1 = inf, q2 = inf;

    if(i+1 < n)

        q1 = abs(a[i] - a[i+1]) + minCost(i+1, a);

        

    if(i+2 < n)

        q2 = abs(a[i] - a[i+2]) + minCost(i+2, a);

    

    return dp[i] = min(q1, q2);



}



int32_t main()

{

    jaiswal_sahil();



    cin>>n;

    int a[n];

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

        cin>>a[i];

    

    memset(dp, -1, sizeof(dp));

    int ans = minCost(0, a);

    cout<<ans<<endl;

    return 0;



}

// Optimized solution to the same problem (faster):
	#include<bits/stdc++.h>

using namespace std;

 

#define int             long long

#define ld              long double

#define ff              first

#define ss              second

#define pb              push_back

#define mp              make_pair

#define pii             pair<int, int>

#define mk(arr,n,type)  type *arr=new type[n];

#define vi              vector<int>

#define si              set<int>

#define usi             unordered_set<int>

#define mii             map<int, int>

#define umii            unordered_map<int, int>

#define pqmax           priority_queue<int>

#define pqmin           priority_queue<int, vi, greater<int> >

#define setbits(x)      __builtin_popcountll(x)

#define trailzrobits(x) __builtin_ctzll(x)

#define leadzrobits(x)  __builtin_clzll(x)

#define paritybits(x)   __builtin_parityll(x)

#define gcd             __gcd

#define lcm(x, y)       (x * y) / gcd(x, y)

#define mod             1000000007

#define endl            '\n'

#define PI              3.14159265358979323846

#define inf             1e18

#define sp(x,y)         fixed<<setprecision(y)<<x



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

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

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

void __print(ld x) {cout<<x;}

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

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

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

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

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

template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}

template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}

#ifndef ONLINE_JUDGE

#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)

#else 

#define dbg(x...)

#endif



int power(int x, int y, int p = mod){

    int res = 1;

    x %= p;

    while(y > 0){

        if(y & 1)

            res = (res * x) % p;

        y = y >> 1;

        x = (x * x) % p;

    }

    return res; 

}



int inv(int x, int p = mod){

    return power(x, p - 2) % p;

}



const int N = 1e6 + 6;

 

int32_t main(){



    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    

    int t = 1;

    // cin >> t;

    while(t--){

        

        int n; cin>>n;

        mk(a, n+1, int);

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

            cin>>a[i];

        

        mk(dp, n+1, int);

        fill(dp, dp+n+1LL, 0);



        dp[2] = abs(a[2] - a[1]);

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

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

        }



        cout<<dp[n];

    }



    return 0;



}

// Fastest known solution for this problem: