1. Why don't teachers teach how to use proper piping with standard input/output? :/ Why ugly up your output and make your program less friendly with unnecessary prompts, and waste time trying to retrieve resources within your program instead of letting the OS take care of that for you?
2. What's the format of your file? Is it supposed to be comma separated values? Remember that by default, scanner scans *space*-separated values. If you are going to use comma-separated values, you need to set the delimiter to a comma as so:
Scanner scan = new Scanner(new File(file)).useDelimiter(",");
It's always usually a good idea to set the delimiter, because the space-character is rarely a useful delimiter, except maybe when you're parsing through the passage of a book or something.
3. You write "here it skips first int and then last 20 ints "
This isn't skipping the first integer. Instead, it's returning it, and it's being used to allocate the integer array. If you still need it, you should assign it to some variable, actually this is a good idea because then you don't need to set "count" to data.length;
Do this instead:
int count = scan.nextInt();
int[] data = new int[count];
for (int i = 0; (i < (count - 1)); i++)
Why is it (count - 1) though? It's generally a strange condition. You would normally loop while (scan.hasNextInt()) instead, but I suppose that it's because you're using an array. The condition I just mentioned would be better if your queue was in a linked list instead.
4. What do you mean by "then last 20 ints"? How does a statement that you called in the beginning of an input stream affect the end of the stream?
I may have to see the actual file that you're working with and the full program.