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

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

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

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

#define DEBUG(x)  cout << #x << " = " << (x) << endl;

#define SORT(x) sort(ALL(x));

#define RSORT(x) sort(RALL(x));

#define SUM(x) accumulate(ALL(x),0);

using namespace std;

using ll = long long;

using vi = vector<int>;

using vvi = vector<vi>;

using pii = pair<int, int>;

using tiii = tuple<int, int, int>;

const int INF = 1e+9;

const ll mod = 1000000007;

const int dx[4] = {1,0,-1,0};

const int dy[4] = {0,1,0,-1};

//cout << fixed << setprecision(10);



ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}

ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}



int h[100010];

int dp[100010];



int main () {

  int N; cin >> N;

  rep(i,N) cin >> h[i];



  dp[0] = 0;

  for (int n = 1; n < 100000; n++) {

    dp[n] = INF;

    dp[n] = min(dp[n], dp[n-1]+abs(h[n-1]-h[n]));

    if (n > 1) {

      dp[n] = min(dp[n], dp[n-2]+abs(h[n-2]-h[n]));

    }

  }



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

}

// Faster C++ solution for the same problem (measured speedup: 1.7294376183547977x):
#include <bits/stdc++.h>

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

#define rrep(i,n) for(int i = 1; i <= (n); ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

#define srep(i,s,t) for (int i = s; i < t; ++i)

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

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

#define limit(x,l,r) max(l,min(x,r))

#define lims(x,l,r) (x = max(l,min(x,r)))

#define isin(x,l,r) ((l) <= (x) && (x) < (r))

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

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

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

#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')

#define showv2(v) rep(j,v.size()) showv(v[j])

#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')

#define showt2(t,r,c) rep(j,r) showt(t[j],c)

#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);

#define printv(v) rep(i,v.size()) printf("%d\n", v[i])

#define printt(t,n) rep(i,n) printf("%d\n", t[i])

#define incl(v,x) find(rng(v),x)!=v.end()

#define fi first

#define se second

#define pb push_back

#define eb emplace_back

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

#define pcnt __builtin_popcountll

#define bn(x) ((1<<x)-1)

#define dup(x,y) (((x)+(y)-1)/(y))

#define newline puts("")

#define uni(x) x.erase(unique(rng(x)),x.end())

#define SP << " " <<

using namespace std;

using ll = long long;

using vi = vector<int>;

using vvi = vector<vi>;

using vll = vector<ll>;

using pii = pair<int, int>;

using tiii = tuple<int, int, int>;

typedef vector<pii> vp;

typedef vector<tiii> vt;

const int mod = 1000000007;

const double EPS = 1e-9;

const int INF = (1<<30)-1;

const ll INFLL = (1LL<<62)-1;

#define dame { puts("No"); return 0;}

#define yn {puts("Yes");}else{puts("No");}

inline int in() { int x; scanf("%d",&x); return x;}

//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main () {

  int n;

  cin >> n;

  vi h(n);

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

  vi dp(n+5,INF);

  dp[0] = 0;

  rep(i,n) {

    if (dp[i] == INF) continue;

    chmin(dp[i+1], dp[i] + abs(h[i]-h[i+1]));

    chmin(dp[i+2], dp[i] + abs(h[i]-h[i+2]));

  }

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

  return 0;

}