My program works correctly, but I have a limit of time 3020ms. how to improve my code?
https://www.e-olymp.com/uk/problems/3607
n- is a number of people, then there are n numbers of input which describe their height, the program should answer the question how much people have a height between a and b (which are also given in input)
import java.io.PrintWriter;
import java.util.Scanner;
public class OlimpGames {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out, true);
{
while (in.hasNextInt()) {
int n = in.nextInt();
int heigh[] = new int[100];
for (int i = 0; i < n; i++) {
heigh[in.nextInt() - 150]++;
}
int a = in.nextInt();
int b = in.nextInt();
int an = 0;
for (int i = a - 150; i <= b - 150; i++) {
an = an + heigh[i];
}
System.out.println(an);
}
}
}
}