#include<bits/stdc++.h>
#define f0(i,n) for(long long int i=0;i<n;i++)
#define f1(i,n) for(long long int i=1;i<=n;i++)
#define f2(i,a,b) for(long long int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
#define nl <<"/n"                  // new line
#define MOD 1000000007              // for mod
#define ll long long
#define ld long double
using namespace std;
// Vector
#define vi vector<int>                  //integer vector
#define vll vector <long long>            // long long vector
#define pb(v,i) v.push_back(i)              //vector element insertion
#define er(v,i) v.erase(v.begin()+i)            // erase ith element in a vector
#define erng(v,x) v.erase(v.begin(),v.begin()+x)        // delete a range in array
#define av(first,last,sum) accumulate(first, last, sum)  //sum of vector
#define vmax(v,x) *max_element(v, v + x)                     //max element in vector
#define vmin(v,x) *min_element(v, v + x)                     //min element in vector
#define sv(v) sort(v.begin(),v.end())                        // sort complete vector
#define svx(v,x) sort(v.begin(),v.begin()+x)                   // sort partial vector
#define low(v,x) *lower_bound (v.begin(), v.end(), x)           //lower bound of a number in vector
#define up(v,x) *upper_bound (v.begin(), v.end(), x)           //upper bound of a number in vector


//Stack
/*  stack<int> s;                       //declaring stack
s.push(1)                       // enter  element in stack
s.top()                         //returns top element in stack
s.pop()                         //removes top element in  stack
*/
// pair
#define pii pair<int,int>                   //pair integers
#define F first
#define S second
#define mp(a,b) make_pair(a,b)          // entering pair element in vector(size not defined)

//Hashmap
/* map<string,string> a;                //declaration
a[“abc”]=”xyz”;                 // element entry in map;
gquiz1.insert(pair<int, int>(1, 40));
map<string,string>::iterator itr;           //iterating map
for (itr = a.begin(); itr!=a.end(); itr++){
    cout <<(*itr).first  << itr->second <<endl;
  }
  itr = companies.find("abc");      //finding element in map
  cout << itz->second;

//*/


                                                 //FUNCTION TO FIND PRIME
/*bool is_prime(int p){
    for(int i = 2; i*i <= p; i++){
        if(p % i == 0) return false;
    }
    return true;
}
*/
/*                                           //DSU by path compression using size
int parent[100005];
int siz[100005];
bool vis[100005];

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void make_set(int v) {
    parent[v] = v;
    siz[v] = 1;
    vis[v]=1;
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (siz[a] < siz[b])
            swap(a, b);
        parent[b] = a;
        siz[a] += siz[b];
    }
}

*/
/*                                                    // DFS FUNCTION
vector<int> graph[100005];
bool vis[100005];

void add_edge(int u,int v){
        pb(graph[u],v);
        pb(graph[v],u);
}

void dfs(int i)
{
    vis[i]=1;

    for(auto j : graph[i])
    {
        if(!vis[j])
            dfs(j);
    }
}
*/

int main()
{
    ll n;
    cin>>n;

    vector <ll> h(n),v(n,10001);
    v[0]=0;

    f0(i,n) cin>>h[i];

    v[1]=abs(h[1]-h[0]);

    for(ll i=2;i<n;i++){
        v[i]=min(abs(h[i]-h[i-1])+v[i-1],abs(h[i]-h[i-2])+v[i-2]);
    }
    
    cout<<v[n-1];
    


    


    return 0;
    }

Measured memory_bytes: 1792