stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const long long INF = 1LL << 60;



int main() {

  int n;

  vector<int> h(100010);

  vector<long long> dp(100010);

  cin >> n;

  for (int i = 0; i < n; i++) cin >> h[i];

  for (int i = 0; i < n; i++) dp[i] = INF;

  dp[0] = 0;



  for (int i = 0; i < n; i++) {

    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]));

    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]));

  }



  cout << dp[n-1] << endl;

}

// Optimized solution to the same problem (faster):
#pragma gcc optimize("Ofast")

#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

#define REP(i, n) FOR(i, 0, n)

#define ALL(V) (V).begin(),(V).end()

#define SORT(V) sort(ALL(V)) //小さい方からソート

#define REV(V) reverse(ALL(V)) //リバース

#define RSORT(V) SORT(V);REV(V) //大きい方からソート

#define NPN(V) next_permutation(ALL(V)) //順列

#define pb(n) push_back(n)

#define endl '\n'

#define Endl '\n'

#define DUMP(x)  cout << #x << " = " << (x) << endl

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl

#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl

#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl

#define RAPID cin.tie(0);ios::sync_with_stdio(false)

#define VSUM(V) accumulate(ALL(V), 0)

#define MID(a,b,c) (a) < (b) && (b) < (c)

#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)

#define IN(n) cin >> n

#define IN2(a,b) cin >> a >> b

#define IN3(a,b,c) cin >> a >> b >> c 

#define IN4(a,b,c,d) cin >> a >> b >> c >> d

#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}

#define OUT(n) cout << n << endl

#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}

#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;



// 型マクロ定義

#define int long long

#define P pair<ll,ll>

#define Vi vector<ll>

#define VVi vector<vector<ll>>

#define Vd vector<double>

#define Vb vector<bool>

#define Vs vector<string>

#define Vc vector<char>

#define M map<ll,ll>

#define S set<ll>

#define PQ priority_queue<ll>

#define PQG priority_queue<ll,V,greater<ll>

//



template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}

template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}



const int MOD = 1000000007;

const int INF = 1061109567;

const double EPS = 1e-10;

const double PI  = acos(-1.0);



int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数

int lcm(int a, int b){return a * b / gcd(a, b);}

string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}

string gCh(string str, int key){return str.substr(key,1);}



signed main() {

  RAPID;

  // デフォルト変数定義

  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;

  string s="",t="";

  //



  // ここから

  IN(n);

  Vi h(n);

  VIN(h)

  int dp[n+10];

  REP(i,n+10) dp[i] = INF;

  dp[0] = 0;

  FOR(i,1,n){

    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));

    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));

  }

  OUT(dp[n-1]);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long       ll;

typedef pair<int,int>   ii;

typedef vector<int>     vi;

typedef vector<ii>      vii;

typedef set<int>        si;

typedef set<ii>         sii;



#define sz(x) (int)x.size()

#define all(x) x.begin(),x.end()

#define clr(x,v) memset(x,v,sizeof x)

#define forn(i,a,b) for(int i=a;i<b;i++)

#define re return



template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }

template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }

template<typename T> T abs (T x)      {re x < 0 ? -x : x; }

template<typename T> T sqr (T x)      {re x*x;}



#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define popcount __builtin_popcount

#define mp make_pair

#define pb push_back

#define ins insert

#define sc second

#define fr first

#define endl "\n"

#define MOD ((int)1e9+7)

#define N ((int)2e5+123)



int n, v[N], dp[N];

int f(int i){

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

    if(i>=n)return MOD;

    if(dp[i]!=-1)return dp[i];

    return dp[i] = min(abs(v[i]-v[i+1])+f(i+1) ,abs(v[i]-v[i+2])+f(i+2));



}

void solve(){

    cin >> n;

    clr(dp,-1);

    forn(i,0,n)cin >> v[i];

    cout << f(0) << endl;

}

int main(){_

    solve();

     /*

    int t; cin >> t;

    while(t--){

        solve();

    }

   */

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long       ll;

typedef pair<int,int>   ii;

typedef vector<int>     vi;

typedef vector<ii>      vii;

typedef set<int>        si;

typedef set<ii>         sii;



#define sz(x) (int)x.size()

#define all(x) x.begin(),x.end()

#define clr(x,v) memset(x,v,sizeof x)

#define forn(i,a,b) for(int i=a;i<b;i++)

#define re return



template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }

template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }

template<typename T> T abs (T x)      {re x < 0 ? -x : x; }

template<typename T> T sqr (T x)      {re x*x;}



#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define popcount __builtin_popcount

#define mp make_pair

#define pb push_back

#define ins insert

#define sc second

#define fr first

#define endl "\n"

#define MOD ((int)1e9+7)

#define N ((int)2e5+123)



int n, v[N], dp[N];



void solve(){

    cin >> n;

    forn(i,0,n)cin >> v[i];

    dp[n-1]=0;dp[n]=MOD;

    for(int i=n-2;i>=0;i--){

        dp[i] = min(abs(v[i]-v[i+1])+dp[i+1], abs(v[i]-v[i+2])+dp[i+2]);

    }

    cout << dp[0] << endl;

}

int main(){_

    solve();

    /*

    int t; cin >> t;

    while(t--){

        solve();

    }

    */

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll; 



const int mxN = 1e5 + 10;

int dp[mxN];



int rec(vector<int>& v, int i, int n) {

	if(i == (n-1)) {

		return dp[n-1] = 0;

	}

	if(dp[i] != -1) return dp[i];

	int ans = INT_MAX;

	if(i + 1 <= n-1)

		ans = min(ans, abs(v[i] - v[i+1]) + rec(v, i+1, n));

	if(i + 2 <= n-1)

		ans = min(ans, abs(v[i] - v[i+2]) + rec(v, i+2, n));

		

	return dp[i] = ans;

}



int main() {

	int n;

	cin >> n;

	vector<int> v(n);

	

	for(int i = 0; i < n; i++) {

		cin >> v[i];

	}

	

	memset(dp, -1, sizeof(dp));

	cout << rec(v, 0, n) << "\n";

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll; 



int main() {

	int n;

	cin >> n;

	vector<int> v(n);

	

	for(int i = 0; i < n; i++) {

		cin >> v[i];

	}

	

	vector<int> dp(n, INT_MAX);

	dp[0] = 0;

	dp[1] = abs(v[0] - v[1]);

	

	for(int i = 2; i < n; i++) {

		dp[i] = min(dp[i-2] + abs(v[i] - v[i-2]), dp[i-1] + abs(v[i] - v[i-1]));

	}

	cout << dp[n-1] << "\n";

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define F first

#define S second

#define pb push_back

#define all(x) (x).begin(),(x).end()

#define sz(x) (int)(x).size()

#define fill(x,v) memset(x, v, sizeof(x))

#define PI (ld)acos(-1)

#define endl '\n'

#define dbg(x) cout<<#x<<"="<<(x)<<endl;

#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 

#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef pair<int,int> pi;

typedef pair<ll,ll> pl;

const ld eps=(ld)1e-9;

const ll inf=(ll)1e18;

const ll mod=(ll)1e9+7;

int n, h[100007],dp[100007];

int f(int i){

	if(i==n-1){

		return 0;

	}

	if(dp[i]!=-1){

		return dp[i];

	}

	int ans=INT_MAX;

	if(i+2<n){

		ans=abs(h[i+2]-h[i])+f(i+2);

	}

	return dp[i]= min(ans,abs(h[i+1]-h[i])+f(i+1));

}





void solve(){

	cin>>n;

	fill(dp,-1);

	for (int i = 0; i < n; ++i)

	{

		cin>>h[i];

	}

	cout<<f(0);

}



int main(){fio;

int test=1;

// cin>>test;

while(test--){

	solve();

	cout<<endl;

}

return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define F first

#define S second

#define pb push_back

#define all(x) (x).begin(),(x).end()

#define sz(x) (int)(x).size()

#define fill(x,v) memset(x, v, sizeof(x))

#define PI (ld)acos(-1)

#define endl '\n'

#define dbg(x) cout<<#x<<"="<<(x)<<endl;

#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 

#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef pair<int,int> pi;

typedef pair<ll,ll> pl;

const ld eps=(ld)1e-9;

const ll inf=(ll)1e9;

const ll mod=(ll)1e9+7;





void solve(){

	int n;

	cin>>n;

	int h[n];

	for (int i = 0; i < n; ++i)

	{

		cin>>h[i];

	}

	vector<int>dp(n,inf);

	dp[0]=0;

	for (int i = 0; i < n; ++i)

	{

		for(int j:{i+1,i+2}){

			if(j<n){

				dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));

			}

		}

	}

	cout<<dp[n-1];

}



int main(){fio;

int test=1;

// cin>>test;

while(test--){

	solve();

	cout<<endl;

}

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

using namespace std::chrono;

int arr[100005];

int n;

int dp[100005];

long long go(int i){

    if(i == n-1)

        return 0;

  	if(i >= n)

      return 1000000;

  int &ans = dp[i];

  if(ans!=-1)

    return ans;



  ans = min(abs(arr[i] - arr[i+1]) + go(i+1) , abs(arr[i] - arr[i+2]) + go(i+2));

  return ans;

}



int main(){

    //auto start = high_resolution_clock::now();

    for(int i = 0 ; i <= 100005 ; i++){

        dp[i] = -1;

    }

	cin >> n;

  	for(int i = 0 ; i < n ; i++)	cin >> arr[i];



  	cout<<go(0)<<"\n";







  	//auto stop = high_resolution_clock::now();



  	//auto duration = duration_cast<milliseconds>(stop - start);

  	//cout<<duration.count();

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

using namespace std::chrono;

int arr[100005];

int n;

long long dp[100005];



int main(){

    //auto start = high_resolution_clock::now();

	cin >> n;

  	for(int i = 1 ; i <= n ; i++)	cin >> arr[i];

  	dp[0] = 100000;

  	dp[1] = 0;

    for(int i = 2 ; i <= n ; i++){

        dp[i] = min(dp[i-2] + abs(arr[i-2] - arr[i]) , dp[i-1] + abs(arr[i-1] - arr[i]));

    }

    cout<<dp[n];

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

  Vivek Rathi

  CSE 2nd Year

  MNNIT

*/

#include<bits/stdc++.h>

using namespace std;

#define M 1000000007

#define ll long long int

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define debug1(x) cout<<#x<<" "<<x<<endl;

#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;

#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

#define present(c,x) ((c).find(x) != (c).end())

#define null NULL

#define mp make_pair

#define fi first

#define se second

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);

#define inf 1e17

#include <ext/pb_ds/assoc_container.hpp> 

#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

ll n,h[100001];

ll dp[100001];

ll solve(ll i)

{

	if(i==n-1)

	{

		return 0;

	}

	if(dp[i]!=-1) return dp[i];

	ll ans1=inf,ans2=inf;

	if(i+2<n)ans1 = abs(h[i]-h[i+2])+solve(i+2);

	if(i+1<n)ans2 = abs(h[i+1]-h[i])+solve(i+1);

	return dp[i]=min(ans1,ans2);

}

int main()

{

	boost

	cin>>n;

	memset(dp,-1,sizeof(dp));

	for(ll i=0;i<n;i++) cin>>h[i];

	cout<<solve(0)<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
/*

  Vivek Rathi

  CSE 2nd Year

  MNNIT

*/

#include<bits/stdc++.h>

using namespace std;

#define M 1000000007

#define ll long long int

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define debug1(x) cout<<#x<<" "<<x<<endl;

#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;

#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

#define present(c,x) ((c).find(x) != (c).end())

#define null NULL

#define mp make_pair

#define fi first

#define se second

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);

#define inf 1e17

#include <ext/pb_ds/assoc_container.hpp> 

#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

int main()

{

	boost

	ll n;

	cin>>n;

	ll h[n];

	for(ll i=0;i<n;i++) cin>>h[i];

	if(n<3)

	{

		if(n==1)

		{

			cout<<0<<endl;

		}

		else if(n==2)

		{

			cout<<abs(h[0]-h[1])<<endl;

		}

		return 0;

	}

	ll dp[n];

	dp[n-2]=abs(h[n-1]-h[n-2]);

	dp[n-3]=min(abs(h[n-1]-h[n-3]),abs(h[n-2]-h[n-3])+dp[n-2]);

	for(ll i=n-4;i>=0;i--)

	{

		dp[i]=min(abs(h[i]-h[i+1])+dp[i+1],abs(h[i+2]-h[i])+dp[i+2]);

	}

	cout<<dp[0]<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define rep(i,n) for (int i=0; i<n; i++)

using namespace std;



int n;

vector<int>h(100000);

vector<int>cost(100000);



int Ans(int n){

    if (cost[n] != -1) return cost[n];

    cost[n] = min((Ans(n-1) + abs(h[n-1] - h[n])),

                  (Ans(n-2) + abs(h[n-2] - h[n])));

    return cost[n];

}



int main(){

    cin>>n;

    rep(i,n){

        cin>>h[i];

        cost[i] = -1;

    }

    cost[0] = 0;

    cost[1] = abs(h[1] - h[0]);

    cout << Ans(n-1) << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;



void solve(int m, vector<int>h){

  	vector<int>cost(m);

    cost[0] = 0;

    cost[1] = abs(h[0] - h[1]);

    for (int i=2; i<m; i++){

        cost[i] = min(

            (cost[i-1] + abs(h[i]-h[i-1])),

            (cost[i-2] + abs(h[i]-h[i-2]))

        );

    }

    cout << cost[m-1];

}



int main(){

  	int n; cin>>n;

  	vector<int>h(n); rep(i,n) cin>>h[i];

  	solve(n, h);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdlib>

using namespace std;



const long long INF = 1LL << 60;



int N;

long long h[100010];

long long dp[100010];



int main() {

  cin >> N;

  for (int i = 0; i < N; i++) cin >> h[i];



  for (int i = 0; i < 100010; i++) dp[i] = INF;



  dp[0] = 0;



  for (int i = 1; i < N; i++) {

    dp[i] = min(dp[i], dp[i - 1] + llabs(h[i] - h[i - 1]));

    if (i > 1) dp[i] = min(dp[i], dp[i - 2] + llabs(h[i] - h[i - 2]));

  }



  cout << dp[N - 1] << endl;



  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <cmath>

using namespace std;



int dp[100010];



int main() {

  int n;

  cin >> n;

  vector<int> h(n);

  for (int i = 0; i < n; i++) {

    cin >> h[i];

  }

  for (int i = 0; i < 100010; i++) {

    dp[i] = 1100000000;

  }

  dp[0] = 0;

  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {

    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

  }

  cout << dp[n - 1] << endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <cmath>

using namespace std;



long long dp[100010];



int main() {

  int n;

  cin >> n;

  vector<long long> h(n);

  for (int i = 0; i < n; i++) {

    cin >> h[i];

  }

  for (int i = 0; i < 100010; i++) {

    dp[i] = 1LL << 60;

  }

  dp[0] = 0;

  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {

    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

  }

  cout << dp[n - 1] << endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <cmath>

using namespace std;



int dp[100010];



int main() {

  int n;

  cin >> n;

  vector<int> h(n);

  for (int i = 0; i < n; i++) {

    cin >> h[i];

  }

  for (int i = 0; i < 100010; i++) {

    dp[i] = 1100000000;

  }

  dp[0] = 0;

  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {

    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

  }

  cout << dp[n - 1] << endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll long long 



#define F first

#define S second



int dx[] = { 0 , 0, 1, -1, -1, -1, 1, 1};

int dy[] = { 1, -1 , 0, 0, 1, -1, 1, -1};

const double EPS= 1e-8 ;

const double PI  = acos(-1.0);

#define inf INT_MAX

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }



int n ; 

int a[100005] ; 

ll dp[100005]; 



ll solve ( int ind )

{

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

	

	if ( dp [ind] != -1 ) return dp[ind]; 

	

	ll & res = dp[ind]; 

	ll res1=1e10 , res2 =1e10 ; 

	if ( ind +1 <n ) 

	res1 = solve ( ind + 1)+ abs ( a[ind] - a[ind+1])  ; 

	if ( ind + 2 <n ) 

	res2 = solve ( ind+2 ) +abs ( a[ind] - a[ind+2]); 

	res = min ( res1 , res2 ); 

	return res ; 

	

}







int main()

 {

 

 cin>>n ; 

  

 for (int i = 0; i < n ; i++)

 {

	 cin>>a[i] ; 

	 

 }

 memset ( dp , -1 , sizeof( dp ) ) ; 

 ll ans = solve ( 0 ) ; 

 

  

cout<< ans << endl; 





 return 0 ;

}













 

 

 

 

 

 



 


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ll long long 



#define F first

#define S second



int dx[] = { 0 , 0, 1, -1, -1, -1, 1, 1};

int dy[] = { 1, -1 , 0, 0, 1, -1, 1, -1};

const double EPS= 1e-8 ;

const double PI  = acos(-1.0);

#define inf INT_MAX

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }











int main()

 {

 int n ; 

 cin>>n ; 

 int a[n] ; 

 for ( int i = 0 ; i< n;i++) cin>>a[i] ; 

 vector < int > dp ( n , inf) ; 

 dp[0]=0; 

 dp[1]= abs ( a[1] -a[0]) ;   

 for ( int i = 2 ; i<n  ;i++) 

  

 {

	 

	 dp[i]= min ( dp[i-2]+abs( a[i-2]-a[i]), dp[i-1]+abs( a[i-1]-a[i])) ; 

 } 

cout<< dp [ n-1] << endl; 





 return 0 ;

}













 

 

 

 

 

 



 


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <assert.h>

#include <stdlib.h>

#include <time.h>

#include <stdio.h>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <string.h>

#include <cmath>

#include <algorithm>

#include <iomanip>

using namespace std;



const int N = 1e5 + 2;



int n, h[N];

long long dp[N];



long long calc(int i)

{

    if (i == n - 1)

    {

        return 0;

    }

    long long &ret = dp[i];

    if (ret != -1)

    {

        return ret;

    }

    ret = 1e9;

    ret = min(ret, calc(i + 1) + abs(h[i + 1] - h[i]));

    if (i + 2 < n)

    {

        ret = min(ret, calc(i + 2) + abs(h[i + 2] - h[i]));

    }

    return ret;

}



int main()

{

    memset(dp, -1, sizeof dp);

    cin >> n;

    for (int i = 0; i < n; ++i)

    {

        cin >> h[i];

    }

    cout << calc(0) << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <assert.h>

#include <stdlib.h>

#include <time.h>

#include <stdio.h>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <string.h>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



const int N = 1e5 + 7;

const long long oo = 1e18L + 5;



int n;



int main() {

    cin >> n;

    vector<int> h(n + 1);

    vector<ll> dp(n + 2, oo);

    for (int i = 0; i < n; ++i) {

        cin >> h[i];

    }

    dp[0] = 0;

    for (int i = 0; i < n; ++i) {

        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));

        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));

    }

    cout << dp[n - 1] << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <assert.h>

#include <stdlib.h>

#include <time.h>

#include <stdio.h>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <string.h>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



const int N = 1e5 + 7;

const long long oo = 1e18L + 5;



int n, h[N];

ll dp[N];



ll go(int i) {

    if (i == n) {

        return 0;

    }

    if (i > n) {

        return oo;

    }

    ll &ret = dp[i];

    if (ret != -1) {

        return ret;

    }

    ret = min(go(i + 1) + abs(h[i] - h[i + 1]), go(i + 2) + abs(h[i] - h[i + 2]));

    return ret;

}



int main() {

    memset(dp, -1, sizeof dp);

    cin >> n;

    for (int i = 1; i <= n; ++i) {

        cin >> h[i];

    }

    cout << go(1) << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <assert.h>

#include <stdlib.h>

#include <time.h>

#include <stdio.h>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <string.h>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



const int N = 1e5 + 7;

const long long oo = 1e18L + 5;



int n;



int main() {

    cin >> n;

    vector<int> h(n + 1);

    vector<ll> dp(n + 2, oo);

    for (int i = 0; i < n; ++i) {

        cin >> h[i];

    }

    dp[0] = 0;

    for (int i = 0; i < n; ++i) {

        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));

        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));

    }

    cout << dp[n - 1] << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

using namespace std;



const long long  INF = 1LL << 60;



int N;

int H[100010];



int main() {

    cin >> N;

    for (int i = 0; i < N; ++i) cin >> H[i];



    long long dp[100010];

    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;



    for (int i = 1; i < N; ++i) {

        dp[i] = min(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]));

        if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]));

    }



    cout << dp[N - 1] << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <cmath>

using namespace std;



const int INF = 1 << 29;



int N;

int H[100010];



int main() {

    cin >> N;

    for (int i = 0; i < N; ++i) cin >> H[i];



    int dp[100010];

    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;



    for (int i = 1; i < N; ++i) {

        dp[i] = min(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]));

        if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]));

    }



    cout << dp[N - 1] << endl;

    return 0;

}

// Fastest known solution for this problem: