If you want to ignore the rest of the input, you can use slicing to accept only the first input n . Example -
n = 6 ar = map(int, raw_input().split(None, n)[:n])
We also use the maxsplit option for str.split so that it is shared only 6 times, then it takes the first 6 elements and converts them to int.
This slightly improves performance. We can also make simple - ar = map(int, raw_input().split())[:n] , but it will be less productive than the above solution.
Demo -
>>> n = 6 >>> ar = map(int, raw_input().split(None, n)[:n]) 1 2 3 4 5 6 7 8 9 0 1 2 3 4 6 >>> print ar [1, 2, 3, 4, 5, 6]
source share