RAINBOWA - Runtime Error

My given below code runs for every input given the sample test case but is giving me a runtime error. Help me with it,

class Extra 
{
    public static void main(String[] args) 
{
    Scanner input = new Scanner(System.in);
    
    int t , n;
            
    t = input.nextInt();
    
    for(int cnt = 0 ; cnt < t ; cnt++)
    {
        int[] a = new int[13];
        n = input.nextInt();
        
        int[] arr = new int[n];
        
        for(int i = 0 ; i < n ; i++)
        {
            arr[i] = input.nextInt();
        }
        
        int k = 1;
        
        int i = 0;
        boolean check = true;
        
        while(arr[i] < 7)
        {
            if(arr[i] == k)
            {
                a[k - 1]++;
                i++;
            }
            else if(arr[i] > k)
            {
                k++;
            }
            else
            {
                check = false;
                break;
            }
        }
        
        if(check == false)
        {
            System.out.println("no");
            continue;
        }
        
        k = 7;
        
        while(i < n)
        {
            if(arr[i] == k)
            {
                a[13 - k]++;
                i++;
            }
            else if(arr[i] < k)
            {
                k--;
            }
            else
            {
                check = false;
                break;
            }
        }
        
        if(check == false)
        {
            System.out.println("no");
            continue;
        }
                    
        for(i = 0 ; i < 6 ; i++)
        {
            if(a[i] != a[12 - i])
            {
                check = false;
            }
        }
        if(check)
            System.out.println("yes");
        else
            System.out.println("no");
    }
}
}