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

using namespace std;



#define mp make_pair

#define pb push_back

#define st first

#define nd second

#define lb lower_bound

#define ub upper_bound



typedef long long ll;

typedef long double ld;

typedef pair<int,int> pi;

typedef pair<ll,ll> pll;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<pi> vpi;

typedef vector<pll> vpll;



const ll oo=1e18;

const int MOD=1000000007;

const int INF=1000000000;

const ld EPS=0.000000001;



int dp[100005],h[100005],n,k=2;



signed main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL);

    cout.tie(NULL);

    memset(dp,0x3f3f,sizeof dp);

    dp[1]=0;

    h[0]=0;

    cin>>n;

    for(int i=1;i<=n;++i) cin>>h[i];

    for(int i=2;i<=n;++i) {

        for(int j=1;j<=min(k,i);++j) {

            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

        }

    }

    cout<<dp[n];

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3727749758746886x):
#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];

    for(int i = 0; i < n; i++)

        dp[i] = 1e9;

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

        int &ans = dp[i];

        if(i == n - 1){

            ans = 0;

            continue;

        }

        ans = 1e9;

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

            if(i + j < n)

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

            else

                break;

        }

    }

    

    cout << dp[0] << '\n';

    EjecuteTime;

    return 0;

}