#include <bits/stdc++.h>
using namespace std;

/*
ORDERED SET
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace __gnu_pbds;
using ordered_set = tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T> ostream& operator<<(ostream &os, ordered_set<T> S){ os << "{ ";for(auto s:S) os<<s<<" ";return os<<"}";}
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set_pair = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
*/

// DEFINE
#define  flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  int long long
#define  double long double
#define  endl "\n"
#define  ff first
#define  ss second
#define  gcd(a,b)       __gcd(a,b)
#define  mem(ar)        memset(ar,0,sizeof ar)
#define  ctone(x)       __builtin_popcount(x)
#define  fr(i,a,b)    for(int i=a;i<b;i++)
#define  shuf(v)        shuffle(v.begin(),v.end(),RNG);
#define  time           cerr << "\nTime elapsed: " << clock() / (double) CLOCKS_PER_SEC << "s\n";

// TEMPLATES
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V) {
    os << '{'; string sep; for (const auto &x : V) os << sep << x, sep = ", "; return os << '}';
}
template<typename T> ostream& operator<<(ostream &os, const vector<pair<T,T>> &V) {
    os << '{'; string sep; for (const auto &x : V) os << sep << '(' << x.ff << "," << x.ss << ')', sep = ", "; return os << '}';
}
template<typename A,typename B> ostream& operator<<(ostream &os, const pair<A, B> &P) {
    return os << '(' << P.first << ", " << P.second << ')';
}
template<typename T> ostream& operator<<(ostream &os, const set<T> &S) {
    os << "{ ";for(auto s:S) os<<s<<" ";return os<<"}";
}
template<typename T> ostream& operator<<(ostream &os, const unordered_set<T> &S) {
    os << "{ ";for(auto s:S) os<<s<<" ";return os<<"}";
}
template<typename L,typename R> ostream& operator<<(ostream &os, const map<L,R> &M) {
    os << "{ ";for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") ";return os<<"}";
}
template<typename L,typename R> ostream& operator<<(ostream &os, const unordered_map<L,R> &M) {
    os << "{ ";for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") ";return os<<"}";
}

template<typename x,typename y> x max(x a,y b){return (a>b)?a:b;}
template<typename x,typename y> x min(x a,y b){return (a<b)?a:b;}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define DEEPAK
#ifdef  DEEPAK
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

// FUNCTIONS
bool isPrime(int n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)
if(n%i==0||n%(i+2)==0)return false;return true;}
const int mod=1e9+7;
inline int add(int x,int y){x+=y;if (x>=mod) return x-mod;return x;}
inline int sub(int x,int y){x-=y;if (x<0) return x+mod;return x;}
inline int mul(int x,int y){return (x*1ll*y)%mod;}
inline int power(int x,int y){int ans=1;while(y){if (y&1) ans=mul(ans,x);x=mul(x,x);y>>=1;}return ans;}
inline int inv(int x){return power(x,mod-2);}
mt19937  RNG(chrono::steady_clock::now().time_since_epoch().count());


int32_t main(){
flash;
int n ; cin >> n;
int h[n];
fr(i,0,n) cin >> h[i];

int dp[n];
dp[0] = 0;
dp[1] = abs(h[1]-h[0]);

for(int i=2;i<n;i++){
    dp[i] = min( dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]) );
    //dbg(dp[i]);
}

cout << dp[n-1] << endl;

return 0;
}


Measured memory_bytes: 5168