#include <bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
typedef vector<point> polygon;
#define X real()
#define Y imag()
#define angle(a) ( atan((a.imag()),a.real() )
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a) * (b)).imag()
const double pi = acos(-1.0);
const double EPS=(1e-7);
typedef tuple <ld, ld, ld> line;

line lineeq(point x, point y)
{
    ll a = y.Y - x.Y;
    ll b = x.X - y.X;
    ll c = -a * x.X - b * x.Y;
    ll gcd = abs(__gcd(a, __gcd(b, c)));
    if(a < 0 || (a == 0 && b < 0))
        gcd *= -1;
    a /= gcd;
    b /= gcd;
    c /= gcd;
    return line(a, b, c);
}
point Getpoint(line l1, line l2)
{
    ld y = (get<0>(l1) * get<2>(l2) - get<0>(l2) * get<2>(l1)) / (get<0>(l2) * get<1>(l1) - get<0>(l1) * get<1>(l2));
    ld x = -1 * (get<1>(l1) * y + get<2>(l1)) / get<0>(l1);
    return point(x, y);
}

bool OnRay(point a, point b, point c)
{

    return dot(b - a, c - a) > EPS;
}

ld dist(point p, point q)
{
    return (p.X - q.X) * (p.X - q.X) + (p.Y - q.Y) * (p.Y - q.Y);
}
const ld angle = 90*pi/180;
point rotateArroundPoint(point p, point a)
{
    return (p - a) * polar((ld) 1, angle) + a;
}
/*
vector<ll>prime_fac;
void primeFactors(ll n)
{
    while (n%2 == 0)
    {
        prime_fac.push_back(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            prime_fac.push_back(i);
            n = n/i;
        }
    }
    if (n > 2)
        prime_fac.push_back(n);
}
*/

ll m;
ll fast_power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return (fast_power(x, y/2)*fast_power(x, y/2));
    else
        return (x*fast_power(x, y/2)*fast_power(x, y/2));
}




/*
ll fac[(int)1e6];
ll mod=1e9+7;
void fact(ll n)
{
 fac[0]=1;
 for(ll i=1;i<n;i++)
        fac[i]=(fac[i-1]*i)%mod;
}
*/

/*
bool prime[1000005];
void SieveOfEratosthenes(ll n)
{

    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
*/

/*

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}
vector<ll>v;
void printPrime(int n)
{
    for (int i = 2; i <= n; i++) {
        if (isPrime(i))
            v.push_back(i);
    }
}
*/

/*
vector<ll>v;
void divesors(ll a)
{
    for(ll i=1;i*i<=a ;i++)
    {
        if(a%i==0)
        {

            if((a/i)==i)
            {

                v.push_back(i);
            }
            else
            {
                v.push_back(i);
                v.push_back(a/i);

            }
        }

    }
}
*/

/*
ld arr[10005][10005];
void Pascal(int n)
{




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

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

        if (line == i || i == 0)
            arr[line][i] = 1;

        else
            arr[line][i] = arr[line - 1][i - 1] +
                            arr[line - 1][i];

        }

    }
}
*/



const int N=1e5 +5;
int ans[N];
int main()
{
    SPEED
    ll n;
    cin >> n;
    ll h[n];
    for(ll i=0;i<n;i++)
    {
        cin >> h[i];
    }
    ans[0]=0;
    ans[1]=abs(h[1]-h[0]);
    for(ll i=2;i<n;i++)
    {
        ans[i]=min(abs(h[i-2]-h[i])+ans[i-2],abs(h[i-1]-h[i])+ans[i-1]);
    }
    cout<<ans[n-1];





    return 0;
}



Measured memory_bytes: 1408