#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const int maxn = 1e5 + 7;
const int maxm = 5e5 + 10;
int s[maxn];
int dp[maxn][2];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;++i)
    cin>>s[i];
    dp[1][0]=dp[1][1]=0;
    dp[0][0]=dp[0][1]=0;
    for (int i=2;i<=n;++i)
    {
        dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(s[i]-s[i-1]);
        dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(s[i]-s[i-2]);
    }
    cout<<min(dp[n][0],dp[n][1])<<endl;
    return 0;
}