Inversion count algorithm
The timeout is caused by a bug is in the ms method.  ms(0,mid)  should be ms(l, mid).

A few comments on the code itself:


Don't use lower case L as a variable name.  It looks too similar to the digit 1.
Don't use static variables to communicate between your methods.  It makes the code harder to test and you risk bugs due to crosstalk between different invocations of the method.  In this case, for example, ms and merge should just return the number of shifts instead of incrementing static counter noi
Better separation of input parsing from actual computation.  You should have a method long countingMergeSort(int[] ary).  That would make it easier for you to test your code.