# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second

using namespace std ;

int n, x ;
vector < int > vc;
int ans[100001] ;

int main() {
    cin >> n ;
    for( int i = 0 ; i < n ; i ++ ) {
        cin >> x ;
        vc.push_back(x) ;
    }
    for( int i = 1 ; i < n ; i ++ ) {
        ans[i] = abs(vc[i] - vc[i-1]) + ans[i-1];
        if( i > 1 ) ans[i] = min(ans[i], abs(vc[i]-vc[i-2]) + ans[i-2] ) ;
    }
    cout << ans[n-1] << endl;
}
