// ॐ त्र्य॑म्बकं यजामहे सु॒गन्धिं॑ पुष्टि॒वर्ध॑नम् ।
                  //  उ॒र्वा॒रु॒कमि॑व॒ बन्ध॑नान् मृ॒त्योर्मुक्षीय॒ मा ऽमृता॑त् 
                  // ॐ नमः शिवाया ॐ नमः शिवाया | हर हर बोले नमः शिवाया 
                   //रामेश्वरए शिवा रामेश्वरए | हर हर बोले नमः शिवाया |
/******HAPPY CODING******
Codechef: ritik_tanwar
*********WITH************
CodeForces:illuminatiiiii
*********RITIK**********/
#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;
#define fi                                         first
#define se                                         second
#define pb                                         push_back
#define int                                        long long int
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqmax                                      priority_queue<int>
#define pqmin                                      priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define dec(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define for1(i,n)                                  for(int i=0;i<n;i++)
#define for2(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       1000001
#define btw(x)                                     (x).begin(),(x).end()
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
int multiplymod(int a,int b){int res=0;while(b){if(b&1){res+=a;}a*=2;b/=2;res%=mod;a%=mod;}return res;}
int expomod(int a,int b,int  m){int res=1;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b = b>>1;}return res;}


int dp[200005];
int func(int *a,int n){
    // if(n<=1) return 0;
    // if(dp[n]!=-1) return dp[n];
    // int op1=func(a,n-1)+abs(a[n]-a[n-1]);
    // int op2=func(a,n-2)+abs(a[n]-a[n-2]);
    // dp[n]=min(op1,op2);
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++){
        int op1=dp[i-2]+abs(a[i]-a[i-2]);
        int op2=dp[i-1]+abs(a[i]-a[i-1]);
        dp[i]=min(op1,op2);

    }
    return dp[n]; 
}

void solve(){
    int n;
    cin>>n;
    int a[200005];
    memset(dp,-1,sizeof dp);
    for2(i,n) cin>>a[i];
    cout<<func(a,n);
}
int32_t main()
{
    fio;
    // test(t){
        solve();
    // }
}

Measured memory_bytes: 5884