Chef and Easy Queries Problem

Please help. Failed at 2 subcases. Cant seem to find the reason.

/* 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
{
Scanner scan = new Scanner(System.in);
int tcases = scan.nextInt();
for (int i = 1; i <= tcases; i++) {

        int n = scan.nextInt();
        int k = scan.nextInt();
        long carry = 0l;
        int j ;
        int count =0 ;

        for (j = 1; j <= n; j++) {
            long n1 = scan.nextLong() + carry;
            carry = n1 - k;
            if (carry < 0l && count==0) {
                System.out.println(j);
                count++;
                break;
            }
        }

        if (count==0) {
            System.out.println(n+1 + (int) (carry / k));
        }

    }
}

}