// Slower C++ solution:
#include <bits/stdc++.h>

#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define ii          pair<int,int>

#define F           first

#define S           second

#define pb          push_back

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

#define rall(x)     (x).rbegin(),(x).rend()

#define fore(i,a,b) for(int i = a;i < b; i+= 1)

#define forr(i,a)   for(int i = a; i >= 0; i--)

#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 

#define w(t)        while(t--)

#define sz(s)       int(s.size())

#define cls(a,car)  memset(a,car,sizeof (a))

#define db(x)       cerr << #x << " is " << x << '\n'

#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);

#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

#define angle(x)    double(x * acos(-1) / 180.0)

using namespace std;

typedef long long   ll;

typedef vector<int> vi;

typedef vector<ii>  vii;

const int N = 1 * 1e5 + 5;

const ll mod = 1e9 + 7;

const double E = 1e-9;

//int dx[] = {1, 0}, dy[] = {0, 1};

//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};

//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};

// fflush(stdout)

// cout << flush

// a + b = a ^ b + 2 * (a & b)

int v[N];

int dp[N];

int n, k = 2;

int f(int i){

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

    int &ans = dp[i];

    if(ans == -1){

        ans = 1e9;

        for(int j = 1; j <= k; j++)

            if(i + j < n)

                ans = min(ans, f(i + j) + abs(v[i] - v[i + j]));

            else

                break;

    }

    return ans;

}

int main(){

    //FL;

    FIN;

    cin >> n;

    fore(i, 0, n)cin >> v[i];

    cls(dp, -1);

    cout << f(0) << '\n';

    

    EjecuteTime;

    return 0;

}       

// Faster C++ solution for the same problem (measured speedup: 1.4535840199358325x):
/* In the name of ALLAH */

#include<bits/stdc++.h>

#include<iostream>

#include<vector>

#include<string>



// MAXIMUM and MINIMUM elements

#define mx_ari(a)   *max_element(a , a+sizeof(a)/4)

#define mn_ari(a)   *min_element(a , a+sizeof(a)/4)

#define mx_arl(a)   *max_element(a , a+sizeof(a)/8)

#define mn_arl(a)   *min_element(a , a+sizeof(a)/8)

#define mx_vec(v)   *max_element(v.begin() , v.end())

#define mn_vec(v)   *min_element(v.begin() , v.end())

// COUNT the occurence of an element

#define cnt_ari(a,b)   count(a , a+sizeof(a)/4 , b)

#define cnt_arl(a,b)   count(a , a+sizeof(a)/8 , b)

#define cnt_vec(v,b)   count(v.begin() , v.end() , b)

// INPUTs

#define sci(a)        scanf("%d",&a)

#define scii(a,b)     scanf("%d %d",&a,&b)

#define sciii(a,b,c)  scanf("%d %d %d",&a,&b,&c)

#define scl(a)        scanf("%lld",&a)

#define scll(a,b)     scanf("%lld %lld",&a,&b)

#define sclll(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)

#define scf(a)        scanf("%f",&a)

#define scff(a,b)     scanf("%f %f",&a,&b)

#define scfff(a,b,c)  scanf("%f %f %f",&a,&b,&c)

#define scd(a)        scanf("%ld",&a)

#define scdd(a,b)     scanf("%lf %lf",&a,&b)

#define scddd(a,b,c)  scanf("%lf %lf %lf",&a,&b,&c)

// OUTPUTs

#define pri(a)        printf("%d ",a)

#define prii(a,b)     printf("%d %d ",a,b)

#define priii(a,b,c)  printf("%d %d %d ",a,b,c)

#define prl(a)        printf("%lld ",a)

#define prll(a,b)     printf("%lld %lld ",a,b)

#define prlll(a,b,c)  printf("%lld %lld %lld ",a,b,c)

#define prd(a)        printf("%.4lf ",a)

#define prdd(a,b)     printf("%.4lf %.4lf ",a,b)

#define prddd(a,b,c)  printf("%.4lf %.4lf %.4lf ",a,b,c)

#define prf(a)        printf("%.4f ",a)

#define prff(a,b)     printf("%.4f %.4f ",a,b)

#define prfff(a,b,c)  printf("%.4f %.4f %.4f ",a,b,c)

// LOOPs

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

#define fol(i,n)      for(long long int i=0;i<n;i++)

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

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

// NEWLINEs

#define nwl           << "\n"

#define nl            printf("\n");

// PAIRs and PUSHbacks

#define mp            make_pair

#define pb            emplace_back

// IMPORTANTs

#define ll          long long

#define ull         unsigned long long int

#define mod         1000000007

#define lcm(a,b)     (a*b) / __gcd(a,b)



using namespace std;











int main()

{

   int n; cin >> n;

   int a[n] , cost[n] , dp[n];

   foi(i,n){

      cin >> a[i];

   }



   cost[n-1] = 0;

   cost[n-2] = abs(a[n-1] - a[n-2]);



   for(int i=n-3; i>=0 ; i--){

      cost[i] = min(cost[i+2]+abs(a[i] - a[i+2]) , cost[i+1]+abs(a[i] - a[i+1]));

   }



   cout << cost[0];



   return 0;

}