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

using namespace std;



typedef signed long long ll;

const int MX = 1e5 + 5;

const int INF = 1e9 + 5;

int n, A[MX], dp[MX];



int solve(int pos) {

    if(pos > n) return INF;

    if(pos == (n - 1)) return 0;

    if(dp[pos] != -1) return dp[pos];

    int ans = INF;

    if(pos + 1 < n) ans = min(ans, abs(A[pos] - A[pos + 1]) + solve(pos + 1));

    if(pos + 2 < n) ans = min(ans, abs(A[pos] - A[pos + 2]) + solve(pos + 2));

    return dp[pos] = ans;

}



int main() {

    scanf("%d", &n);



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

        scanf("%d", &A[i]);

    }

    memset(dp, -1, sizeof(dp));

    printf("%d\n", solve(0));

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3684104493486x):
// Author : Syed Mujtaba

// Seek knowledge from the Cradle to the Grave !!

// https://www.linkedin.com/in/syed-mujtaba-064a5016a  



#include <bits/stdc++.h>

using namespace std;

#define int             long long

#define ld              long double

#define ll              long long

#define vi              vector < int >

#define pb              push_back

#define mk              make_pair

#define fi              first

#define se              second

#define f               first

#define s               second

#define mod             1000000007 // 1e9 + 7

#define inf             1000000007 // 1e9 + 7

#define MAX             10000007   // 1e7 + 7

#define test            int t; cin>>t; while(t--)

#define eps             1e-6

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

#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define basic           ll NN; cin >> NN; vector < int >  a(NN); for(ll i = 0;i < NN;i++) cin >> a[i];



// int fact[1000007]={0};

// int spf[(int)(1e6)];

// bool prime[(int)((1e7) + 20)];

// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}

// void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}

// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}

// int xyp(int x,int y){int res=1;while(y>0){if(y%2==1) res=(res*x)%mod;x=(x*x)%mod;y/=2;}return res%mod;}

// int inv(int x){return xyp(x,mod - 2);}

// void init() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}

// int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[r],mod-2)))%mod; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res;}

// int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res; }

// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}

// int add(int a, int b){return (a%mod + b%mod)%mod;}

// int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}

// int mul(int a, int b){return ((a%mod)*(b%mod))%mod;}

// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 

int32_t main()

{

	fast_io

	int n;

	cin >> n;

	vector < int > dp(n + 1, 0), v(n);

	for(auto &z : v)

		cin >> z;

	dp[1] = 0;

	dp[2] = abs(v[1] - v[0]);

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

	{

		dp[i] = min(dp[i - 1] + abs(v[i - 1] - v[i - 2]), dp[i - 2] + abs(v[i - 1] - v[i - 3]));

	}

	cout << dp[n] << endl;

}