我一般这样处理多组输入: while True: try: n = int(input()) nums = list(map(int, input().split())) # solve(n, nums) except: break