stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int a,b,c,d,dp[100000],cost[100000],weight[100];



void func(int a)

{

    dp[1]=0;

    dp[2]=abs(cost[1]-cost[2]);

    for(int i=3; i<=a; i++)

    {

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

    }

}



int main()

{

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

    cin>>a;

    for(int i=1; i<=a; i++)

    {

        cin>>cost[i];

    }

    func(a);

    cout<<dp[a]<<endl;

    //cout<<nCr(a,b)<<endl;



}


// Faster C++ solution for the same problem (measured speedup: 1.3785765848780769x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include <bits/stdc++.h>

#define F first

#define S second

#define T second.first

#define C second.second

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int,pair<int,int>> piii;



const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;

const ll M=10 ;

const double ESP = 1e-8;



int n;

int A[N], dp[N];

int main(){

    FIO

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    cin>>n;

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

    memset(dp, OO, sizeof dp);

    dp[0] = 0;

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

        if(i+1<n){

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

        }

        if(i+2<n){

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

        }

    }

    cout<<dp[n-1];



}


// Faster C++ solution for the same problem (measured speedup: 1.3953555982347245x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

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

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



const int N = 1e5 + 9;

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



int sol(int i){

    if(i<0) return 1e9;

    if(i==0) return 0;



    if(~dp[i]) return dp[i];



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

}





int main() {



    cin >> n;



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



    memset(dp, -1, sizeof dp);



    cout << sol(n - 1);

}

// Faster C++ solution for the same problem (measured speedup: 1.3814198239491662x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include <bits/stdc++.h>

#include <ext/numeric>



using namespace std;

using namespace __gnu_cxx;



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

#define endl "\n"

#define pb push_back

#define F first

#define S second

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

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMN INT_MIN

#define IMX INT_MAX

#define pow(n, m) power((ll)n, (ll)m)

#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)

#define mem(x, val)    memset(x, val, sizeof(x))



typedef long long ll;

typedef long double ld;

typedef double dd;

typedef string str;

typedef pair<int, int> pii;





vector<int> v;

int dp[(int)1e5];

int n;

int jump(int i){

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

    if(i>=n) return 1e9;



    int &ret = dp[i];



    if(~ret) return ret;



    int cnt = 0;

    if(i+1<n) cnt = abs(v[i] - v[i+1]) + jump(i+1);

    if(i+2<n) cnt = min(cnt, abs(v[i] - v[i+2]) + jump(i+2));



    return ret = cnt;

}

int main()

{

    THINK_TWICE_CODE_ONCE

    //freopen("test cases\\.txt", "r", stdin) ;

    cin>>n;

    v.resize(n);

    for(int &i: v) cin>>i;

    mem(dp, -1);

    cout<<jump(0);

    return 0;

}










// Faster C++ solution for the same problem (measured speedup: 1.3973969341392094x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include <bits/stdc++.h>

//freopen("transmitters.in","r",stdin);

//cout<<fixed<<setprecision(6)<<n<<endl;

// transform(s.begin(), s.end(), s.begin(), ::tolower);

//double PI=3.14159265359,c=0;

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

#define endl '\n'

#define ll long long

//#define f(n) for(int i=;i<n;i++)

double PI = acos(-1);

using namespace std;

void fast()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

}

int arr[1000005], n;

vector<int>v(1e5+2, -1);

int minCost(int indx)

{

	int path1=INT_MAX, path2=INT_MAX;

	if (indx == n - 1)

		return 0;



	if (v[indx] != -1)

		return v[indx];



	if (indx + 1 < n)

		path1 = abs(arr[indx] - arr[indx + 1]) + minCost(indx + 1);



	if (indx + 2 < n)

		path2 = abs(arr[indx] - arr[indx + 2]) + minCost(indx + 2);



	return v[indx] = min(path1, path2);

}

int main()

{

	fast();

	cin >> n;

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

		cin >> arr[i];



	cout << minCost(0) << endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4008056003678988x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



const int N=1e5+30;

typedef long long ll;

int n,arr[N];

int dp[N];

ll solve(int i){

    if(i>=n)return 1e15;

    if(i==n-1){

        return 0;

    }



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



    ll path1=abs(arr[i]-arr[i+1])+solve(i+1);

    ll path2=abs(arr[i]-arr[i+2])+solve(i+2);

    return dp[i]= min(path1,path2);

}

int main()

{

    memset(dp,-1,sizeof dp);

    scanf("%d",&n);

    for(int i=0;i<n;i++)scanf("%d",arr+i);

    cout<<solve(0)<<endl;

}




// Faster C++ solution for the same problem (measured speedup: 1.3776617358470455x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <cstring>

using namespace std;



int n;

int ht[100010];

int eg[100010];//eg[i] 代表到达i点消耗的最少能量 

int main(){

	cin>>n;

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

		cin>>ht[i];

		

	}//读取完毕

	memset(eg, 0, sizeof(eg));

	eg[2] = abs(ht[2]- ht[1]);

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

		int t1 = abs(ht[i] - ht[i-1]);

		int t2 = abs(ht[i] - ht[i-2]);

		eg[i] = min(eg[i-1]+t1, eg[i-2]+t2); 

	}

	cout<<eg[n]<<endl;

		

}

// Faster C++ solution for the same problem (measured speedup: 1.383079987793133x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#define __USE_MINGW_ANSI_STDIO

#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include <unordered_set>

#include <unordered_map>



using namespace std;



typedef long long ll;

typedef long long ull;

typedef pair<ll, ll> ii;



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

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

#define endl		"\n"

#define fx(n)		fixed<<setprecision(n)

#define mk			make_pair	



void File()

{

#ifndef ONLINE_JUDGE

	freopen("output.txt", "w", stdout);

	freopen("input.txt", "r", stdin);

#endif

#ifdef ONLINE_JUDGE

	/*freopen("output.txt", "w", stdout);

	freopen("pyramid.in", "r", stdin);*/

#endif

}

void fast()

{

	ios::sync_with_stdio(NULL);

	cout.tie(NULL);

	cin.tie(NULL);

	//File();

}

const double pi = 2 * acos(0.0);

const ll oo = 0x3f3f3f3f;

const int MOD = 1e9 + 7;

const int nn = 1e5 + 15;

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

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



int n;

ll arr[nn];

ll dp[nn];

int main()

{

	fast();

	cin >> n;

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

		cin >> arr[i];

	memset(dp, oo, sizeof dp);

	dp[0] = 0;

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

	{

		if (i == 1)

			dp[i] = abs(arr[i - 1] - arr[i]) + dp[0];

		else

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

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7969003841382594x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
// Slower C++ solution:
#include "bits/stdc++.h"

    

using namespace std;

vector<long long >dp(100001,-1);

vector<long long>num;

long long  erg(int n){

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

		return dp[n];

	}

	if(n<0){

		return 2000000000000;

	}

	if(n==0){

		return 0;

	}

	long long cmp1=max(num[n],num[n-1])-min(num[n],num[n-1]),cmp2=max(num[n],num[n-2])-min(num[n],num[n-2]);

	dp[n]= min(erg(n-1)+cmp1,erg(n-2)+cmp2);

	return dp[n];

}

int main() {

	int menge,numm;

	cin>>menge;

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

		cin>>numm;

		num.push_back(numm);

	}

cout<<erg(menge-1);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7897369120221764x):
#include <bits/stdc++.h>



#define cn count

#define pb push_back

#define in insert

#define fs first

#define sc second

#define sz size

#define len length

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)

#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)

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



using namespace std;

using ll = long long;

const ll inf = 1e9+7; 

const double PI =  3.141592653589793;



int main(){

	IO;

	ll n;

	cin>>n;

	ll dp[n],h[n];

	dp[0]=0;

	forn(i,n){

		cin>>h[i];

	}

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

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

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

	}

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

	return 0;

}





// _   .-')                .-. .-')                 .-')                                               

//( '.( OO )_              \  ( OO )               ( OO ).                                             

// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 

// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '

// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |

// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |

// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |

// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '

// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""