#include using namespace std; const int MAX_N = 40000 + 10; int v[MAX_N]; int n; long long sum = 0; int must; bitset DP[MAX_N]; //DP[i][j] = can we obtain sum i from the first j elements int main() { cin >> n; for(int i = 1; i <= n; ++i) { cin >> v[i]; v[i] = v[i] % n; if(v[i] == 0) { cout << "1\n"; cout << i << "\n"; return 0; } } sort(v + 1, v + n + 1); DP[0][0] = 1; for(int i = 0; i < n; ++i) { for(int j = 1; j <= n; ++j) { if(!DP[i][j - 1]) continue; int nxt = i + v[j]; if(nxt >= n) nxt -= n; DP[i][j] = 1; DP[nxt][j] = 1; } } assert(DP[0][n] == 1); vector ans; int s = 0; int at = n; while(at > 0) { int prev = s - v[at]; if(prev < 0) prev += n; if(DP[prev][at - 1]) { //we got to (s, at) from (prev, at - 1) //so we included v[at] ans.push_back(at); s = prev; --at; } else { //we did not include v[at] --at; } } cout << ans.size() << "\n"; for(auto i: ans) cout << i << " "; cout << "\n"; return 0; }