There are 2 (TWO) lines in the sample. First contains count of stones, second contains stones weights.
Your test should look like:
---
6
1 4 5 6 7 9
---
By the way some languages (C scanf/C++ iostream/Java scanners) allow reading from input without checking how data items are placed on input lines.
Here -
http://acm.timus.ru/help.aspx?topic=csharp - input read in similar way via
string[] input = Console.In.ReadToEnd().Split(
new char[] {' ', '\t', '\n', '\r'},
StringSplitOptions.RemoveEmptyEntries);