I have this loop here
for(int i =0; i < prices.length; i++)
largest = prices[i];
You could just add the requirement to the loop control condition:
for(int i =0; i < prices.length && i < 20; i++)
This would check the first 20 elements where ther are more than 20 in the array, but the whole array if there are less than 20 items.