I Don't konw why it showing run time error cananyone help??

Problem name: link–> CodeChef

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s=new Scanner(System.in);
		 long k=s.nextInt();
		 while(k-->0)
		 {
		     int a[]=new int[10];
		     int c=s.nextInt();
		     int flag=0;
		  while(c-- >0){
		         int n=s.nextInt();
		         a[n]++;
		  }
		         
		         
		         for (int i=0;i<=9;i++)
		         {
		          if(!(a[i]==0||a[i]==i))
		          {
		           System.out.println("NO");
		           flag=1;
		           break;
		          }
		         }
		         if(flag!=1)
		         System.out.println("YES");
		     }
		 }
	}



@blaze_madhu - this problem code has doubt support. - CodeChef
you can ask the doubt solvers and they will help you resolve this.