Array Transform | ARRAYTRM

Why the size of the common array is K+1 in the below give code?
can some one explain the logic form for the line? common[sc.nextInt() % (k+1)] += 1;

public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

    for (int t = 0; t < T; t++) {
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] common = new int[k+1];
        for (int i = 0; i < n; i++) {
            common[sc.nextInt() % (k+1)] += 1;
        }
        boolean maindone = false;
        boolean seenone = false;

        int diff = 0;
        int ones = 0;
        for (int i = 0; i < k+1; i++) {
            if (common[i] > 0){
                diff += 1;
                if (common[i] == 1) {
                    ones += 1;
                }
            }
        }

        if (diff == 1 || (diff == 2 && ones >= 1)){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

}

//