Count Inversions Hackerrank Python