#include using namespace std; using LL = long long; #define FOR(i, l, r) for(int i = (l); i <= (r); ++i) #define REP(i, n) FOR(i, 0, (n) - 1) #define ssize(x) int(x.size()) template auto& operator<<(ostream &o, pair p) { return o << '(' << p.first << ", " << p.second << ')'; } template auto operator<<(ostream &o, T x) -> decltype(x.end(), o) { o << '{'; int i = 0; for(auto e : x) o << (", ")+2*!i++ << e; return o << '}'; } #ifdef DEBUG #define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n' #else #define debug(...) {} #endif const int C = 10; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector v(n + 1), pref(n + 1); vector > rest(C); rest[0].emplace_back(0); FOR(i, 1, n) { cin >> v[i]; pref[i] = pref[i - 1] + v[i]; pref[i] %= C; rest[pref[i]].emplace_back(i); } REP(i, C) { if (!rest[i].empty()) rest[i].emplace_back(rest[i].back() - 1); } rest[pref[n]].pop_back(); int prev, ans; vector to_print; for (int i = n; i > 0; i--) { prev = pref[i - 1]; ans = rest[prev].back(); rest[prev].pop_back(); ans -= rest[prev].back(); to_print.emplace_back(ans); } cout << to_print.back(); for (int i = ssize(to_print) - 2; i >= 0; i--) cout << " " << to_print[i]; cout << '\n'; return 0; }