#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    return gcd(b, a % b);  
      
}
/*void build(ll node,ll start,ll end)
{
    if(start==end)
    {
        tree[node]=a[start];
        
    }
    else
    {
        ll mid = (start+end)/2;
        build(2*node+1,start,mid);
        build(2*node+2,mid+1,end);
        tree[node]=gcd(tree[2*node+1],tree[2*node+2]);
    }
}
void update(ll tree[],ll node,ll start,ll end,ll idx)
{
    if(start==end)
    {
        tree[node] = max(0LL,tree[node]-1);
    }
    else
    {
        ll mid = (start+end)/2;
        if(start<=idx && mid>=idx)
        {
            update(tree,2*node+1,start,mid,idx);
        }
        else
        {
            update(tree,2*node+2,mid+1,end,idx);
        }
        tree[node] = tree[2*node+1]+tree[2*node+2];
    }
}
ll query(ll node,ll start,ll end,ll l,ll r)
{
    if(r<start || l>end)
    {
        return 0;
    }
    if(l<=start && r>=end)
    {
        return tree[node];
    }
    ll mid = (start+end)/2;
    ll p1 = query(2*node+1,start,mid,l,r);
    ll p2 = query(2*node+2,mid+1,end,l,r);
   return gcd(p1,p2);
}
*/
std::vector<ll> path;
void dfs(int x,std::vector<ll> v[],int visited[])
{
    visited[x]=1;
    path.pb(x);
    for(int i=0;i<v[x].size();i++)
    {
        if(!visited[v[x][i]])
        {
            dfs(v[x][i],v,visited);
            path.pb(x);
        }
    }
}
std::vector<ll> v;
int go(ll a,ll b)
{
    if(a==b)
    {
        v.pb(a);
        return 1;
    }
    if(a>b)
        return 0;
    else
    {
        int f = go(2*a,b);
        if(f==1)
        {
            v.pb(a);
            return 1;
        }
        f= go(10*a+1,b);
        if(f==1)
        {
            v.pb(a);
            return 1;
        }
        return 0;
    }
}
int main()
{                       
    fastio();
  
    ll n;
    cin>>n;
    ll a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+1]={0};
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792