// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define gc getchar_unlocked

#define fo(i,n) for(i=0;i<n;i++)

#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)

#define ll long long

#define si(x)	scanf("%d",&x)

#define sl(x)	scanf("%lld",&x)

#define ss(s)	scanf("%s",s)

#define pi(x)	printf("%d\n",x)

#define pl(x)	printf("%lld\n",x)

#define ps(s)	printf("%s\n",s)

#define deb(x) cout << #x << "=" << x << endl

#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

#define pb push_back

#define mp make_pair

#define F first

#define S second

#define all(x) x.begin(), x.end()

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

#define PI 3.1415926535897932384626

typedef pair<int, int>	pii;

typedef pair<ll, ll>	pl;

typedef vector<int>		vi;

typedef vector<ll>		vl;

typedef vector<pii>		vpii;

typedef vector<pl>		vpl;

typedef vector<vi>		vvi;

typedef vector<vl>		vvl;

int mpow(int base, int exp); 

void ipgraph(int m);

void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

//=======================



vi g[N];

int a[N];

int dp[300000];

int solve(int a[],int i,int n){

if(i>=n-1)return 0;

if(dp[i]!=-1)return dp[i];

if(i<n-2){

    return dp[i]=min(solve(a,i+1,n)+abs(a[i]-a[i+1]),solve(a,i+2,n)+abs(a[i]-a[i+2]));

}

else return dp[i]=solve(a,i+1,n)+abs(a[i]-a[i+1]);

}

int main() {

    ios_base::sync_with_stdio(0);

   ll int t, i, j, k, p, q, r, x, y, u, v, n, m;

    //cin>>t;

   t=1; 

   memset(dp,-1,sizeof dp);

   while(t--){

    cin>>n;

    int a[n];

    fo(i,n)cin>>a[i];

    cout<<solve(a,0,n);





    }

    return 0;

}




// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define gc getchar_unlocked

#define fo(i,n) for(i=0;i<n;i++)

#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)

#define ll long long

#define si(x)	scanf("%d",&x)

#define sl(x)	scanf("%lld",&x)

#define ss(s)	scanf("%s",s)

#define pi(x)	printf("%d\n",x)

#define pl(x)	printf("%lld\n",x)

#define ps(s)	printf("%s\n",s)

#define deb(x) cout << #x << "=" << x << endl

#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

#define pb push_back

#define mp make_pair

#define F first

#define S second

#define all(x) x.begin(), x.end()

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

#define PI 3.1415926535897932384626

typedef pair<int, int>	pii;

typedef pair<ll, ll>	pl;

typedef vector<int>		vi;

typedef vector<ll>		vl;

typedef vector<pii>		vpii;

typedef vector<pl>		vpl;

typedef vector<vi>		vvi;

typedef vector<vl>		vvl;

int mpow(int base, int exp);

void ipgraph(int m);

//void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

const ll INF=1e18L+5;

// ll int dp[2090][3000]; 

ll int dp[200000];

int solve(int a[],int n,int i){

    if(i==n){

        return 0;



    }

    if(i==n-1)return 0;

    if(dp[i]!=-1)return dp[i];

    if(i<n-2)

    return dp[i]=min(solve(a,n,i+1)+abs(a[i]-a[i+1]),solve(a,n,i+2)+abs(a[i]-a[i+2]));

    else{

    return dp[i]=solve(a,n,i+1)+abs(a[i]-a[i+1]);

    }

}



int main(){

ios_base::sync_with_stdio(0);

ll int t,n,i,j,k,m;

t=1;

memset(dp,-1,sizeof dp);

// cin>>t;

int T;

Fo(T,1,t+1){

//  cout<<"Case #"<<T<<": ";

    cin>>n;

    int a[n];



    fo(i,n){

        cin>>a[i];

    }

    cout<<solve(a,n,0);



}



}


// Fastest known solution for this problem: