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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

 

typedef long long            ll;

typedef unsigned long long   ull;

typedef vector<int>          vi;

typedef vector<ll>           vl;

typedef pair<int, int>       pi;

typedef pair<ll, ll>         pl;

typedef vector<pi>           vpi;

typedef vector<pl>           vpl;

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

 

#define read        freopen("in.c", "r", stdin)

#define write       freopen("out.c", "w", stdout)

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

#define bye         exit(0)

#define mp          make_pair

#define ff          first

#define ss          second

#define L(x)        ((x) << 1)

#define R(x)        ((x) << 1 | 1)

#define SZ(a)       (ll)(a).size()

#define pb          push_back

#define eb          emplace_back

#define eps         1e-9

#define inf         (1000000000)

#define infl        (1000000000000000000LL)

#define cs(p)       printf("Case %d:", (p)++)

#define ptc(c)      putchar(c)

#define gtc()       getchar()

#define nl          puts("")

#define sp          printf(" ")

#define out(a)      printf("%lld", (ll)(a))

#define SET(a, x)   memset((a), x, sizeof(a))

#define dbg(x)      cerr << "--- " << #x << " = " << (x) << '\n'

 

ll bgm(ll a, ll b, ll m) {

    b = (b == -1) ? (m - 2) : b;

    a %= m;

    ll rem = 1;

    while(b != 0) {

        if(b&1)

            rem = (rem * a) % m;

        a = (a * a) % m;

        b >>= 1;

    }

    return rem;

}

 

inline ll in() {

    ll a;

    assert(scanf("%lld", &a) != EOF);

    return a;

}

 

const int MAX = 100000 + 5;

const int LEN = 50;

const ll MOD = 1000000007;

 

int n;

ll a[MAX];

 

ll dp[MAX];

 

ll solve(int pos) {

    if(pos > n) {

        return inf;

    }

    if(pos == n) {

        return 0;

    }

    ll &ret = dp[pos];

    if(ret != -1) {

        return ret;

    }

    return ret = min(abs(a[pos + 1] - a[pos]) + solve(pos + 1), abs(a[pos + 2] - a[pos]) + solve(pos + 2));

}

 

int main() {

  	SET(dp, -1);

    n = in();

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

        a[i] = in();

    }

    out(solve(1)), nl;

    return 0;

}

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



typedef long long            ll;

typedef unsigned long long   ull;

typedef vector<int>          vi;

typedef vector<ll>           vl;

typedef pair<int, int>       pi;

typedef pair<ll, ll>         pl;

typedef vector<pi>           vpi;

typedef vector<pl>           vpl;

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;



#define read        freopen("in.c", "r", stdin)

#define write       freopen("out.c", "w", stdout)

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

#define UNI(a)      a.resize(unique(all(a), a.begin()) - a.begin())

#define bye         exit(0)

#define mp          make_pair

#define ff          first

#define ss          second

#define L(x)        ((x) << 1)

#define R(x)        ((x) << 1 | 1)

#define SZ(a)       (ll)(a).size()

#define pb          push_back

#define eb          emplace_back

#define eps         1e-9

#define inf         (1000000000)

#define infl        (1000000000000000000LL)

#define cs(p)       printf("Case %d:", (p)++)

#define ptc(c)      putchar(c)

#define gtc()       getchar()

#define nl          puts("")

#define sp          printf(" ")

#define out(a)      printf("%lld", (ll)(a))

#define SET(a, x)   memset((a), x, sizeof(a))

#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'



ll bgm(ll a, ll b, ll m) {

    b = (b == -1) ? (m - 2) : b;

    a %= m;

    ll rem = 1;

    while(b != 0) {

        if(b&1) {

            rem = (rem * a) % m;

        }

        a = (a * a) % m;

        b >>= 1;

    }

    return rem;

}



inline ll in() {

    ll a;

    assert(scanf("%lld", &a) != EOF);

    return a;

}



const int MAX = 100000 + 5;

const int LEN = 50;

const ll MOD = 1000000007;



int n;

int h[MAX];



int dp[MAX];



int main() {

    n = in();

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

        h[i] = in();

    }

    dp[0] = inf;

    dp[1] = 0;

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

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

    }

    out(dp[n]), nl;

    return 0;

}