Error in my Code..Why?

Problem Link :-1: Problem - 1138A - Codeforces

import java.util.Scanner;

/**
*

  • @author abhishekraj
    */
    public class Codefor {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      int count1=Integer.MIN_VALUE,count2=Integer.MIN_VALUE,max1=Integer.MIN_VALUE,max2=Integer.MIN_VALUE,ans=Integer.MIN_VALUE;
      Scanner sc = new Scanner(System.in);
      long n=sc.nextLong();
      int a[] = new int[(int)n];
      for(int i=0;i<n;i++)
      {
      a[i]=sc.nextInt();
      }
      for(int i=0;i<n-1;i++)
      {

      if(a[i]==1)
      {
          if(a[i]==a[i+1])
          {
              count1++;
              if(max1<count1)
              {
                  max1=count1;
              }
          }
      }
      
      if(a[i]==2)
      {
          if(a[i]==a[i+1])
          {
              count2++;
              if(max2<count2)
              {
                  max2=count2;
              }
          }
      }
      

      }

      ans= 1+Math.min(max1, max2);
      System.out.println(2*ans);
      }

}

Can Anyone why I got this Error :-

100000
2 1 2 1 1 1 1 1 2 1 1 2 2 2 1 2 1 1 2 2 1 2 2 2 2 1 1 1 1 2 1 2 2 1 2 2 2 1 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 1 1 2 2 1 2 2 2 2 1 2 2 1 2 1 2 2 2 2 2 2 1 2 1 2 2 1 1 1 1 2 2 2 1 1 2 2 2 2 2 1 2 2 1 2 1 2 1 1 1 1 2 1 1 1 2 1 1 2 2 1 1 2 1 2 1 1 1 1 1 2 2 1 2 2 1 2 1 2 1 1 1 1 1 2 1 2 1 2 1 1 1 2 2 1 2 1 1 2 1 1 1 2 1 2 1 2 2 1 2 1 2 2 1 1 2 2 1 1 1 1 1 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 1 1 1 2 2 1 2 1 1 1 1 2 1 1 2 1 2 1 1 1 1 2 2 1 1 1 2 2 2 1 2 1 2 2 1 2 1 1 2 2 2 2 1 2 2 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2…
Exception in thread β€œmain” java.util.InputMismatchException
at java.base/java.util.Scanner.throwFor(Scanner.java:939)
at java.base/java.util.Scanner.next(Scanner.java:1594)
at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at codefor.Codefor.main(Codefor.java:26)
/Users/abhishekraj/NetBeansProjects/codefor/nbproject/build-impl.xml:1330: The following error occurred while executing this line:
/Users/abhishekraj/NetBeansProjects/codefor/nbproject/build-impl.xml:936: Java returned: 1
BUILD FAILED (total time: 11 seconds)