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



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

ll mod = 998244353;

#define EPS 1e-1

#define PI 3.14159265



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

#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

using namespace std;



ll fastpow(ll base, ll pow)

{

    if (!base)

        return 0;

    if (!pow)

        return 1;

    if (pow == 1)

        return base;

    ll x = fastpow(base, pow / 2) % mod;

    x *= x;

    x %= mod;

    if (pow % 2)

        x *= base;

    return x % mod;

}



ll inverse(ll x)

{

    return fastpow(x, mod - 2) % mod;

}



ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];

void init()

{

    fact[0] = inv[0] = 1;

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

    {

        fact[i] = (i * fact[i - 1]) % mod;

        inv[i] = inverse(fact[i]);

    }

}



void factorize(ll x, map<int, int> &ss)

{

    while (x % 2 == 0)

        ss[2]++, x /= 2;

    for (int i = 3; i <= sqrt(x); i += 2)

        while (x % i == 0)

            ss[i]++, x/= i;

    if (x > 2)

        ss[x]++;

}



ll ncr(ll n, ll r)

{

    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;

}



ll npr(ll n, ll r)

{

    return (fact[n] * inv[n - r]) % mod;

}



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

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



int n;

ll arr[(int)1e5 + 5];

ll dp[(int)1e5 + 5];



ll solve(int idx)

{

    if (idx == n)

        return 0;

    if (dp[idx] != -1)

        return dp[idx];

    ll res = 1e9;

    if (idx + 1 < n)

        res = min(res, abs(arr[idx] - arr[idx + 1]) + solve(idx + 1));

    else if (idx + 1 == n)

        res = min(res, solve(idx + 1));

    if (idx + 2 < n)

        res = min(res, abs(arr[idx] - arr[idx + 2]) + solve(idx + 2));

    else if (idx == n)

        res = min(res, solve(idx + 2));

    return dp[idx] = res;

}



int main()

{

    fastio

    cin >> n;

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

        cin >> arr[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0);

    return 0;

}


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



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

ll mod = 1e9 + 7;

#define EPS 1e-1

#define PI 3.14159265



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

#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

using namespace std;



ll fastpow(ll base, ll pow)

{

    if (!base)

        return 0;

    if (!pow)

        return 1;

    if (pow == 1)

        return base;

    ll x = fastpow(base, pow / 2) % mod;

    x *= x;

    x %= mod;

    if (pow % 2)

        x *= base;

    return x % mod;

}



ll inverse(ll x)

{

    return fastpow(x, mod - 2) % mod;

}



ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];

void init()

{

    fact[0] = inv[0] = 1;

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

    {

        fact[i] = (i * fact[i - 1]) % mod;

        inv[i] = inverse(fact[i]);

    }

}



void factorize(ll x, map<int, int> &ss)

{

    while (x % 2 == 0)

        ss[2]++, x /= 2;

    for (int i = 3; i <= sqrt(x); i += 2)

        while (x % i == 0)

            ss[i]++, x/= i;

    if (x > 2)

        ss[x]++;

}



ll ncr(ll n, ll r)

{

    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;

}



ll npr(ll n, ll r)

{

    return (fact[n] * inv[n - r]) % mod;

}



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

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



int arr[(int)1e5 + 5];

int dp[(int)1e5 + 5];

    int n;



ll solve(int idx)

{

    if (idx >= n - 1)

        return 0;

    if (dp[idx] != -1)

        return dp[idx];

    int c1 = 1e9;

    if (idx + 1 < n)

    {

        c1 = 0;

        c1 = abs(arr[idx] - arr[idx + 1]) + solve(idx + 1);

    }

    int c2 = 1e9;

    if (idx + 2 < n)

    {

        c2 = 0;

        c2 = abs(arr[idx] - arr[idx + 2]) + solve(idx + 2);

    }

    return dp[idx] = min(c1, c2);

}



int main()

{

    fastio

    memset(dp, -1, sizeof dp);

    cin >> n;

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

        cin >> arr[i];

    cout << solve(0);

    return 0;

}