The condition that you should display maximum of N numbers, is not matched. But output looks correct. I can't find where is the problem..