#include #include using namespace std; int main() { uint32_t n; cin >> n; vector coach(n); for(uint32_t i = 0; i < n; i++) { scanf("%hhi", &coach[i]); } vector res(n, -1); vector waiters(10, -1); uint8_t total = 0; for(uint32_t i = 0; i < n; i++) { if(coach[i] == 0) { res[i] = 1; } else { waiters[total] = i; total = (total + coach[i]) % 10; if(waiters[total] != -1) { res[waiters[total]] = i - waiters[total] + 1; waiters[total] = -1; } } } printf("%i", res[0]); for(uint32_t i = 1; i < n; i++) { printf(" %i", res[i]); } printf("\n"); return 0; } /*int main() { uint32_t n; cin >> n; vector coach(n); for(uint32_t i = 0; i < n; i++) { scanf("%hhi", &coach[i]); } vector finished(n, false); vector sums(n, 0); vector res(n, 0); uint32_t last = 0; for(uint32_t i = 0; i < n; i++) { for(int a = 0; a < n; a++) { printf("%i ", sums[a]); } printf("\n"); for(uint32_t x = last; x <= i; x++) { if(finished[x]) { continue; } sums[x] += coach[i]; res[x]++; if(sums[x] % 10 == 0) { finished[x] = true; if(x == last) { last++; } } } } for(uint32_t i = last; i < n; i++) { if(!finished[i]) { res[i] = -1; } } printf("%i", res[0]); for(uint32_t i = 1; i < n; i++) { printf(" %i", res[i]); } printf("\n"); return 0; }*/