// 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.7848987161942067x):
#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];

    dp[0] = 0;

    dp[1] = abs(arr[0] - arr[1]);

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

    {

        int c1 = dp[i - 1] + abs(arr[i] - arr[i - 1]);

        int c2 = dp[i - 2] + abs(arr[i] - arr[i - 2]);

        dp[i] = min(c1, c2);

    }

    cout << dp[n - 1];

    return 0;

}