HackerRank - Cracking the Code Interview - Time Complexity: Primality

Here's my Java solution for HackerRank and Cracking the Code Interview's Time Complexity: Primality problem.

import java.io.*;  
import java.util.*;  
import java.text.*;  
import java.math.*;  
import java.util.regex.*;

public class Solution {

    private static boolean isPrime(int n) {
        if (n <= 1) return false;

        if (n % 2 == 0) return false;

        for (int i = 3; i * i <= n; i+=2) {
            if(n % i == 0) return false;
        }

        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int p = in.nextInt();
        for(int a0 = 0; a0 < p; a0++){
            int n = in.nextInt();
            if (isPrime(n)) System.out.println("Prime");
            else System.out.println("Not prime");
        }
    }
}