Language: Java

import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner();
    int n=sc.nextInt();
    int h[]=new int[n];
    for(int i=0;i<n;i++)
    {
      h[i]=sc.nextInt();
    }
    int min[]=new int[n];
    min[0]=h[0];
    min[1]=h[1]-h[0];
    for(int i=2;i<n;i++)
    {
     int h1=(int)Math.abs(ar[i]-ar[i-1])+h[i-1];
     int h2=(int)Math.abs(ar[i]-ar[i-2])+h[i-2];
      h[i]=h1>h2?h1:h2;
    }
    System.out.println(h[n-1]);
  }
}

Compiler output:
Main.java:6: error: no suitable constructor found for Scanner(no arguments)
    Scanner sc=new Scanner();
               ^
    constructor Scanner.Scanner(Readable,Pattern) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Readable) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,CharsetDecoder) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,Charset) is not applicable
      (actual and formal argument lists differ in length)
Main.java:18: error: cannot find symbol
     int h1=(int)Math.abs(ar[i]-ar[i-1])+h[i-1];
                          ^
  symbol:   variable ar
  location: class Main
Main.java:18: error: cannot find symbol
     int h1=(int)Math.abs(ar[i]-ar[i-1])+h[i-1];
                                ^
  symbol:   variable ar
  location: class Main
Main.java:19: error: cannot find symbol
     int h2=(int)Math.abs(ar[i]-ar[i-2])+h[i-2];
                          ^
  symbol:   variable ar
  location: class Main
Main.java:19: error: cannot find symbol
     int h2=(int)Math.abs(ar[i]-ar[i-2])+h[i-2];
                                ^
  symbol:   variable ar
  location: class Main
5 errors