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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)

#define endl "\n"

#define int long long

typedef vector<int> vi;

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

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

#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

#define pii              pair <int,int>

#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;

typedef long long ll;

//#pragma comment(linker, "/STACK:667772160")

#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))



const double eps=1e-9;

const int MOD=1e9+7;

const int N=1e5+30;

const int inf = 1e17+995;



template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }

template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}

inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

void boostIO() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int mem[N],n ,tall[N];

int dp(int idx){

 if(idx==n-1)

     return 0;

 if(idx>n-1)

     return inf;

    int &ret=mem[idx];

    if(ret!=-1)

   return ret;

    ret=min(abs(tall[idx]-tall[idx+1])+dp(idx+1),abs(tall[idx]-tall[idx+2])+dp(idx+2));



    return ret;

}

int32_t main() {

boostIO();

cin>>n;

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

        cin>>tall[i];

    }

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

    int ans=dp(0);

    cout<<ans<<endl;

}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)

#define endl "\n"

#define int long long

typedef vector<int> vi;

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

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

#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

#define pii              pair <int,int>

#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;

typedef long long ll;

//#pragma comment(linker, "/STACK:667772160")

#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))



const double eps=1e-9;

const int MOD=1e9+7;

const int N=1e5+30;

const int inf = 1e17+995;



template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }

template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}

inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

void boostIO() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}



int32_t main() {

boostIO();

int n;

cin>>n;

vi h(n);

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

        cin>>h[i];

    }

    vi dp(n,inf);

    dp[0]=0;

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

        for(int j:{i+1,i+2}){

            if(j<n){

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

            }

        }

    }

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

}

// Fastest known solution for this problem: