#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int N = 1e5+7;
int arr[N];
int dp[N];
int f(int idx, int n){
if(idx >= n){
return 0;
}
if(dp[idx]!=-1) return dp[idx];
int op1 = abs(arr[idx+1]-arr[idx])+f(idx+1, n);
int op2 = abs(arr[idx+2]-arr[idx])+f(idx+2, n);
return dp[idx]=min(op1,op2);
}
int main() {
int n;
cin>>n;
for(int i=1; i<=n; i++){
cin>>arr[i];
}
memset(dp, -1, sizeof(dp));
cout<<f(1, n)<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nIGludApjb25zdCBpbnQgTiA9IDFlNSs3OwppbnQgYXJyW05dOwppbnQgZHBbTl07CgppbnQgZihpbnQgaWR4LCBpbnQgbil7CglpZihpZHggPj0gbil7CgkJcmV0dXJuIDA7Cgl9CglpZihkcFtpZHhdIT0tMSkgcmV0dXJuIGRwW2lkeF07CglpbnQgb3AxID0gYWJzKGFycltpZHgrMV0tYXJyW2lkeF0pK2YoaWR4KzEsIG4pOwoJaW50IG9wMiA9IGFicyhhcnJbaWR4KzJdLWFycltpZHhdKStmKGlkeCsyLCBuKTsKCXJldHVybiBkcFtpZHhdPW1pbihvcDEsb3AyKTsKfQoKaW50IG1haW4oKSB7CglpbnQgbjsKCWNpbj4+bjsKCWZvcihpbnQgaT0xOyBpPD1uOyBpKyspewoJCWNpbj4+YXJyW2ldOwoJfQoJbWVtc2V0KGRwLCAtMSwgc2l6ZW9mKGRwKSk7Cgljb3V0PDxmKDEsIG4pPDxlbmRsOwoJcmV0dXJuIDA7Cn0=