//                                             ,---------,
//                                           ,"        ,"|
//      ,------------------------,|        ,"        ,"  |
//      +-----------------------+ |      ,"        ,"    |
//      |  .-----------------.  | |     +---------+      |
//      |  |                 |  | |     | -==----'|      |
//      |  |  Keep Calm AND  |  | |     |         |      |
//      |  |   FUCK YOU :))  |  | |/----|`---=    |      |
//      |  |  C:\>_          |  | |   ,/|==== ooo |      ;
//      |  |                 |  | |  // |(((( [33]|    ,"
//      |  `-----------------'  |, .;'| |((((     |  ,"
//      +-----------------------+  ;; | |         |,"
//         /_)______________(_/  //'   |+---------+
//    ___________________________/___  `,
//   /  oooooooooooooooo  .o.  oooo /,   \,"-----------
//  / ==ooooooooooooooo==.o.  ooo= //   ,`\--{)B     ,"
// /_==__==========__==_ooo__ooo=_/'   /___________,"
// `-----------------------------'

#include/*       .     .       .  .   . .   .   . .    +  .                 */  <bits/stdc++.h>
        /*       .     .  :     .    .. :. .___---------___.                */
        /*            .  .   .    .  :.:. _".^ .^ ^.  '.. :"-_. .           */
   using/*         .  :       .  .  .:../:            . .^  :.:\.           */  namespace std;
        /*             .   . :: +. :.:/: .   .    .        . . .:\          */
        /*      .  :    .     . _ :::/:               .  ^ .  . .:\         */
 typedef/*       .. . .   . - : :.:./.                        .  .:\        */  vector< int > vi;
        /*      .      .     . :..|:                    .  .  ^. .:|        */
        /*         .       . : : ..||        .                . . !:|       */
 #define/*       .     . . . ::. ::\(                           . :)/       */  fast_baby ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        /*      .   .     : . : .:.|. ######              .#######::|       */
        /*       :.. .  :-  : .:  ::|.#######           ..########:|        */
 #define/*      .  .  .  ..  .   . :\ ########          :######## :/        */  ll long long
        /*       .        .+ :: : -.:\ ########       . ########.:/         */
        /*         .  .+   . . . . :.:\. #######       #######..:/          */
 #define/*           :: . . . . ::.:..:.\           .   .   ..:/            */  pop pop_back()
        /*        .   .   .  .. :  -::::.\.       | |     . .:/             */
        /*           .  :  .  .  .-:.":.::.\             ..:/               */
 #define/*      .      -.   . . . .: .:::.:.\.           .:/                */  pb push_back
        /*     .   .   .  :      : ....::_:..:\   ___.  :/                  */
        /*        .   .  .   .:. .. .  .: :.:.:\       :/                   */
 #define/*          +   .   .   : . ::. :.:. .:.|\  .:/|                    */  endl '\n'
        /*          .         +   .  .  ...:: ..|  --.:|                    */
        /*     .      . . .   .  .  . ... :..:.."(  ..)"                    */
 #define/*      .   .       .      :  .   .: ::/  .  .::\                   */  str string

//Can You hear me?
ll a,dp[100100],h[100100];
int main()
{
	fast_baby
	cin>>a;
	for(int q=0;q<a;q++)
        cin>>h[q];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<a;i++)
        dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
    cout<<dp[a-1];
return 0;
} //Va menallaha tofigh :))


Measured memory_bytes: 1792