Help me in solving ZEROSTRING problem

My issue

find eror

My code

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

class Codechef {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-- > 0) {
            int n = sc.nextInt();
            int count = 0;
            int a[] = new int[n];
            for(int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }
            // Move the counting logic outside the array population loop
            for(int i = 0; i < n; i++) {
                if(a[i] == 1) {
                    count++;
                }
            }
            if(count % 2 == 0 && count > 0) {
                System.out.println(2);
            } else if(count == 0) {
                System.out.println(0);
            } else {
                System.out.println(1);
            }
        }
    }
}

Problem Link: Zero String Practice Coding Problem