Error in Ist test Case

Everytime this error occurs

when i try to submit
runguard: warning: timelimit exceeded (wall time): aborting command runguard: warning: command terminated with signal 15

My code is
import java.util.*;

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

    while (t-- > 0) {
        int n = scanner.nextInt();
        int[] primes = generatePrimes(n);
        int cost = primes[n - 1]; // Minimum cost is the nth prime number
        
        System.out.println(cost);
    }
    
    scanner.close();
}

// Function to generate the first n prime numbers
private static int[] generatePrimes(int n) {
    int[] primes = new int[n];
    int count = 0;
    int num = 2;
    
    while (count < n) {
        if (isPrime(num)) {
            primes[count] = num;
            count++;
        }
        num++;
    }
    
    return primes;
}

// Function to check if a number is prime
private static boolean isPrime(int num) {
    if (num <= 1) {
        return false;
    }
    
    for (int i = 2; i * i <= num; i++) {
        if (num % i == 0) {
            return false;
        }
    }
    
    return true;
}

}

@budhirajarahul25 you need to apply SOE approach for this question to improve time complexity. This will be taught later in your course.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.