#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
// your code goes here
ll n;
cin>>n;
ll i=1;
ll height[n+1];
while(i<=n)
{
cin>>height[i];
i++;
}
ll dp[n+1]={0};
dp[1]=0;
dp[2]=abs(height[1]-height[2]);
i=3;
while(i<=n)
{
ll x = abs(height[i-1]-height[i]);
ll y = abs(height[i-2]-height[i]);
dp[i]=min(dp[i-1]+x, y+dp[i-2]);
i++;
//cout<<i<<" "<<dp[i]<<"\n";
}
cout<<dp[n];
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgbG9uZyBsb25nIGludCBsbDsKCgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCWxsIG47CgljaW4+Pm47CglsbCBpPTE7CglsbCBoZWlnaHRbbisxXTsKCXdoaWxlKGk8PW4pCgkgewoJIAljaW4+PmhlaWdodFtpXTsKCSAJaSsrOwoJIH0KCSAKCSAKCSBsbCBkcFtuKzFdPXswfTsKCSBkcFsxXT0wOwoJIGRwWzJdPWFicyhoZWlnaHRbMV0taGVpZ2h0WzJdKTsKCSAKCSBpPTM7Cgkgd2hpbGUoaTw9bikKCSAgewoJICAJbGwgeCA9IGFicyhoZWlnaHRbaS0xXS1oZWlnaHRbaV0pOwoJICAJbGwgeSA9IGFicyhoZWlnaHRbaS0yXS1oZWlnaHRbaV0pOwoJICAJZHBbaV09bWluKGRwW2ktMV0reCwgeStkcFtpLTJdKTsKCSAgCWkrKzsKCSAgCS8vY291dDw8aTw8IiAiPDxkcFtpXTw8IlxuIjsKCSAgCQoJICB9CgkgIAoJICBjb3V0PDxkcFtuXTsKCQoJcmV0dXJuIDA7CgkKCQoJCgkKCQoJCgkKCQoJCgkKCQoJCgkKCQoJCgkKCQoJCgkKCQoJCn0=