#include using namespace std; const int INF = 1000000000; int main() { int N, K, M; cin >> N >> K; cin >> M; vector A(N + 1); long long S = 0; for (int i = 1; i <= N; i++) { cin >> A[i]; S += A[i]; } if (S % (N + 1) != 0) { cout << -1 << '\n'; return 0; } long long T = S / (N + 1); if (T < 1) { cout << -1 << '\n'; return 0; } vector W(N + 1); for (int i = 1; i <= N; i++) { W[i] = A[i] - T; if (W[i] < 0) { cout << -1 << '\n'; return 0; } } if (W[M] < 1) { cout << -1 << '\n'; return 0; } if (A[M] - 2 < K) { cout << -1 << '\n'; return 0; } int m = (int)(T - 1); vector B(N + 1, 0); vector rem(N + 1, 0); vector deadline(N + 1, INF); vector deadline_count(max(1, m) + 1, 0); int sumB = 0; for (int i = 1; i <= N; i++) { int b = W[i] - (i == M ? 1 : 0); if (b < 0) { cout << -1 << '\n'; return 0; } B[i] = b; rem[i] = b; sumB += b; if (b > 0) { int d = K + 1 - b; if (d < 1) { cout << -1 << '\n'; return 0; } int effective_deadline = min(d, m); deadline[i] = effective_deadline; deadline_count[effective_deadline] += b; } } assert(sumB == m); if (m == 0) { cout << 1 << '\n'; cout << M << '\n'; return 0; } vector slack(m + 1, INF); int pref = 0; for (int x = 1; x <= m; x++) { pref += deadline_count[x]; slack[x] = x - pref; if (slack[x] < 0) { cout << -1 << '\n'; return 0; } } assert(pref == m); vector ans; ans.reserve((size_t)T); for (int p = 1; p <= m; p++) { int min_deadline = INF; for (int i = 1; i <= N; i++) { if (rem[i] > 0) { min_deadline = min(min_deadline, deadline[i]); } } if (min_deadline < p) { cout << -1 << '\n'; return 0; } int E = m + 1; for (int x = p; x <= m; x++) { if (slack[x] == 0) { E = x; break; } } int c = -1; for (int i = 1; i <= N; i++) { if (rem[i] > 0 && deadline[i] <= E) { c = i; break; } } if (c == -1) { cout << -1 << '\n'; return 0; } ans.push_back(c); for (int x = p; x < deadline[c]; x++) { slack[x]--; if (slack[x] < 0) { cout << -1 << '\n'; return 0; } } rem[c]--; } for (int i = 1; i <= N; i++) { assert(rem[i] == 0); } ans.push_back(M); cout << ans.size() << '\n'; for (int i = 0; i < (int)ans.size(); i++) { if (i) cout << ' '; cout << ans[i]; } cout << '\n'; return 0; }