import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n=int(readline()) m=list(map(int, read().split())) s=[0] for x in m: s+=[(x+y)%1000 for y in s] INF=10**9 dp=[INF]*(1<x: dp[i^(1<