#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
int n,h[N];
int dp[N];

int solve(int idx){

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

    int& ret = dp[idx];
    if(~ret)
        return ret;

    ret = min(solve(idx+1)+abs(h[idx]-h[idx+1]) , solve(idx+2)+abs(h[idx]-h[idx+2]));
    return ret;
}

/*
void build(int idx){

    if(idx == n)
        return ;

    int& ret = dp[idx];
    if(ret == solve(idx+1)+abs(h[idx]-h[idx+1])){
        cout << abs(h[idx]-h[idx+1]) << " ";
        build(idx+1);
        return;
    }
    if(ret == solve(idx+2)+abs(h[idx]-h[idx+2])){
        cout << abs(h[idx]-h[idx+2]) << " ";
        build(idx+2);
        return;
    }
   // ret = min(solve(idx+1)+abs(h[idx]-h[idx+1]) , solve(idx+2)+abs(h[idx]-h[idx+2]));
    return ;
}

*/

    
int main(){
    

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);

    
    scanf("%d",&n);
    loop(i, n) scanf("%d",h+i); 

    memset(dp ,-1 , sizeof dp);
    printf("%d\n",solve(0));
   // build(0);
    //puts("");


    


    return 0;
}