#include #define debug(x) cerr << #x << ": " << x << '\n' #define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vll; const ll INF = INT_MAX; const ll MOD = 1e9+7; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N;cin>>N; ll M[N];for(ll i=0;i>M[i]; ll dp[1<>i)&1){ dis = (dis+M[i])%1000; } for(ll i=0;i>i)&1)){ dp[S|(1<