#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
int h[100000];
int dp[100000];
int main()
{
	memset(dp, 0, sizeof(dp));
	int n,temp,dp1,dp2;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &temp);
		h[i] = temp;
	}
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
	{
		dp1 = dp[i - 1] + abs(h[i] - h[i - 1]);
		dp2 = dp[i - 2] + abs(h[i] - h[i - 2]);
		dp[i] = dp1 < dp2 ? dp1 : dp2;
	}
	printf("%d", dp[n - 1]);
}