Can't get rid of NZEC Error

Contest Code:[PRACTICE] Problem Code:[JOHNY]
In my novice eyes it’s looking like I’m using the exact same logic as other accepted submissions in C#. My code is running fine in Visual Studio. I just don’t understand why I keep getting NZEC error.
Please help!

int T = Int32.Parse(Console.ReadLine());
            for (int i = 0; i < T; i++)
            {

                int N = Int32.Parse(Console.ReadLine());
                long[] songs = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt64(x));
                int K = Int32.Parse(Console.ReadLine());
                long johnylen = songs[K-1];
                Array.Sort(songs);
                Console.WriteLine(Array.IndexOf(songs, johnylen)+1);

               
            }

Why did you copy the code inside the main method instead of just all of the code? Us who don’t know the specifics of C# have to guess how to structure your code to make it work.

As for the NZEC, your program doesn’t like how the input is formatted. For the third array you have to read in, there’s an extra space at the end of the line, and I guess that makes your program try to convert an empty string to a number? I don’t know C#, but there’s probably a way to fix that. To see this for yourself, highlight all of the input and compare the third array with the other two, which don’t crash.

Thanks for your reply. I’m not sure what you mean by third array since I’m using only one long type array in code…
Are you referring to the 3 test cases in sample input? Whatever problem you mentioned, why would this only happen in the CodeChef IDE and not in Visual studio? I’m pasting my complete code here for reference

using System;
using System.Collections.Generic;

namespace JOHNY
{
class Program
{
static void Main(string[] args)
{
int T = Int32.Parse(Console.ReadLine());
for (int i = 0; i < T; i++)
{

            int N = Int32.Parse(Console.ReadLine());
            long[] songs = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt64(x));
            int K = Int32.Parse(Console.ReadLine());
            long johnylen = songs[K-1];
            Array.Sort(songs);
            Console.WriteLine(Array.IndexOf(songs, johnylen)+1);

            
        }
    }
}

}

Yes, the sample input. Not sure why it would be a difference in IDE, maybe it’s the way input is fed to the program. Do you know of a way to handle an arbitrary number of spaces at the end?