Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var A = cin.scanint;
        var dp = new int[N];
        for (int i = 0; i < N; i++)
        {
            dp[i] = int.MaxValue;
        }
        dp[0] = 0;
        for (int i = 1; i < N; i++)
        {
            dp[i] = dp[i - 1] + Math.Abs(A[i] - A[i - 1]);
            if (i > 1) chmin(ref dp[i], dp[i - 2] + Math.Abs(A[i] - A[i - 2]));
        }
        WriteLine(dp[N - 1]);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.IO;
      |       ^~~~~~
a.cc:9:7: error: expected nested-name-specifier before 'static'
    9 | using static System.Console;
      |       ^~~~~~
a.cc:22:5: error: 'readonly' does not name a type
   22 |     readonly Scanner cin = new Scanner();
      |     ^~~~~~~~
a.cc:23:5: error: 'readonly' does not name a type
   23 |     readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
      |     ^~~~~~~~
a.cc:24:5: error: 'readonly' does not name a type
   24 |     readonly int mod = 1000000007;
      |     ^~~~~~~~
a.cc:25:10: error: variable or field 'chmax' declared void
   25 |     void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
      |          ^~~~~
a.cc:25:10: error: expected ';' at end of member declaration
   25 |     void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
      |          ^~~~~
      |               ;
a.cc:25:15: error: expected unqualified-id before '<' token
   25 |     void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
      |               ^
a.cc:26:10: error: variable or field 'chmin' declared void
   26 |     void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
      |          ^~~~~
a.cc:26:10: error: expected ';' at end of member declaration
   26 |     void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
      |          ^~~~~
      |               ;
a.cc:26:15: error: expected unqualified-id before '<' token
   26 |     void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
      |               ^
a.cc:46:2: error: expected ';' after class definition
   46 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Program::Main()':
a.cc:19:22: error: expected ';' before '.' token
   19 |         new Program().solve();
      |                      ^
a.cc:20:9: error: 'Out' was not declared in this scope
   20 |         Out.Flush();
      |         ^~~
a.cc: In member function 'void Program::solve()':
a.cc:30:17: error: 'cin' was not declared in this scope
   30 |         int N = cin.nextint;
      |                 ^~~
a.cc:31:9: error: 'var' was not declared in this scope
   31 |         var A = cin.scanint;
      |         ^~~
a.cc:32:13: error: expected ';' before 'dp'
   32 |         var dp = new int[N];
      |             ^~
a.cc:35:13: error: 'dp' was not declared in this scope
   35 |             dp[i] = int.MaxValue;
      |             ^~
a.cc:35:21: error: expected primary-expression before 'int'
   35 |             dp[i] = int.MaxValue;
      |                     ^~~
a.cc:37:9: error: 'dp' was not declared in this scope
   37 |         dp[0] = 0;
      |         ^~
a.cc:40:33: error: 'Math' was not declared in this scope
   40 |             dp[i] = dp[i - 1] + Math.Abs(A[i] - A[i - 1]);
      |                                 ^~~~
a.cc:40:42: error: 'A' was not declared in this scope
   40 |             dp[i] = dp[i - 1] + Math.Abs(A[i] - A[i - 1]);
      |                                          ^
a.cc:41:30: error: 'ref' was not declared in this scope
   41 |             if (i > 1) chmin(ref dp[i], dp[i - 2] + Math.Abs(A[i] - A[i - 2]));
      |                              ^~~
a.cc:41:24: error: 'chmin' was not declared in this scope
   41 |             if (i > 1) chmin(ref dp[i], dp[i - 2] + Math.Abs(A[i] - A[i - 2]));
      |                        ^~~~~
a.cc:43:9: error: 'WriteLine' was not declared in this scope
   43 |         WriteLine(dp[N - 1]);
      |         ^~~~~~~~~
a.cc: At global scope:
a.cc:50:5: error: 'string' does not name a type
   50 |     string[] s; int i;
      |     ^~~~~~
a.cc:51:5: error: 'readonly' does not name a type
   51 |     readonly char[] cs = new char[] { ' ' };
      |     ^~~~~~~~
a.cc:52:11: error: expected ':' before 'Scanner'
   52 |     public Scanner() { s = new string[0]; i = 0; }
      |           ^~~~~~~~
      |           :
a.cc:53:11: error: expected ':' before 'string'
   53 |     public string[] scan { get { return ReadLine().Split(); } }
      |           ^~~~~~~
      |           :
a.cc:53:12: error: 'string' does not name a type
   53 |     public string[] scan { get { return ReadLine().Split(); } }
      |            ^~~~~~
a.cc:54:11: error: expected ':' before 'int'
   54 |     public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
      |           ^~~~
      |           :
a.cc:54:15: error: expected unqualified-id before '[' token
   54 |     public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
      |               ^
a.cc:55:11: error: expected ':' before 'long'
   55 |     public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
      |           ^~~~~
      |           :
a.cc:55:16: error: expected unqualified-id before '[' token
   55 |     public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
      |                ^
a.cc:56:11: error: expected ':' before 'double'
   56 |     public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
      |           ^~~~~~~
      |           :
a.cc:56:18: error: expected unqualified-id before '[' token
   56 |     public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
      |                  ^
a.cc:57:11: error: expected ':' before 'string'
   57 |     public string next
      |           ^~~~~~~
      |           :
a.cc:57:12: error: 'string' does not name a type
   57 |     public string next
      |            ^~~~~~
a.cc:69:11: error: expected ':' before 'int'
   69 |     public int nextint { get { return int.Parse(next); } }
      |           ^~~~
      |           :
a.cc:69:58: error: expected ';' at end of member declaration
   69 |     public int nextint { get { return int.Parse(next); } }
      |                                                          ^
      |                                                           ;
a.cc:70:11: error: expected ':' before 'long'
   70 |     public long nextlong { get { return long.Parse(next); } }
      |           ^~~~~
      |           :
a.cc:70:61: error: expected ';' at end of member declaration
   70 |     public long nextlong { get { return long.Parse(next); } }
      |                                                             ^
      |                                                              ;
a.cc:71:11: error: expected ':' before 'double'
   71 |     public double nextdouble { get { return double.Parse(next); } }
      |           ^~~~~~~
      |           :
a.cc:71:67: error: expected ';' at end of member declaration
   71 |     public double nextdouble { get { return double.Parse(next); } }
      |                                                                   ^
      |                                                                    ;
a.cc:72:11: error: expected ':' before 'void'
   72 |     public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
      |           ^~~~~
      |           :
a.cc:72:17: error: variable or field 'join' declared void
   72 |     public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
      |                 ^~~~
a.cc:72:17: error: expected ';' at end of member declaration
   72 |     public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
      |                 ^~~~
      |                     ;
a.cc:72:21: error: expected unqualified-id before '<' token
   72 |     public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
      |                     ^
a.cc:73:2: error: expected ';' after class definition
   73 | }
      |  ^
      |  ;
a.cc:69:26: error: 'get' was not declared in this scope
   69 |     public int nextint { get { return int.Parse(next); } }
      |                          ^~~
a.cc:69:30: error: expected '}' before '{' token
   69 |     public int nextint { get { return int.Parse(next); } }
      |                              ^
a.cc:69:24: note: to match this '{'
   69 |     public int nextint { get { return int.Parse(next); } }
      |                        ^
a.cc:69:30: error: cannot convert '<brace-enclosed initializer list>' to 'int' in initialization
   69 |     public int nextint { get { return int.Parse(next); } }
      |                              ^
a.cc:69:30: error: expected ';' before '{' token
a.cc:70:28: error: 'get' was not declared in this scope
   70 |     public long nextlong { get { return long.Parse(next); } }
      |                            ^~~
a.cc:70:32: error: expected '}' before '{' token
   70 |     public long nextlong { get { return long.Parse(next); } }
      |                                ^
a.cc:70:26: note: to match this '{'
   70 |     public long nextlong { get { return long.Parse(next); } }
      |                          ^
a.cc:70:32: error: cannot convert '<brace-enclosed initializer list>' to 'long int' in initialization
   70 |     public long nextlong { get { return long.Parse(next); } }
      |                                ^
a.cc:70:32: error: expected ';' before '{' token
a.cc:71:32: error: 'get' was not declared in this scope
   71 |     public double nextdouble { get { return double.Parse(next); } }
      |                                ^~~
a.cc:71:36: error: expected '}' before '{' token
   71 |     public double nextdouble { get { return double.Parse(next); } }
      |                                    ^
a.cc:71:30: note: to match this '{'
   71 |     public double nextdouble { get { return double.Parse(next); } }
      |                              ^
a.cc:71:36: error: cannot convert '<brace-enclosed initializer list>' to 'dou