#include using namespace std; using ll = long long; using ld = long double; // #define int long long #define pii pair #define pll pair #define vi vector #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define mp make_pair #define pb push_back #define sz(v) (int)(v).size() // #define endl '\n' const ld eps = 1e-8; const ll mod = 1e9 + 7; const int inf0 = 1e9 + 10; const ll inf = 2e18 + 10; void solve(); signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef LC freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif cout << fixed << setprecision(20); int t = 1; //cin >> t; while (t--) { solve(); } return 0; } const int N = 1e6, LOGG = 20; ll d[N]; int ans[N]; int nextt[LOGG][N]; ll edge_len[LOGG][N]; void solve() { int n; ll c; cin >> n >> c; ll summ = 0; for (int i = 0; i < n; ++i) { cin >> d[i]; summ += d[i]; } if (summ <= c || n == 1) { for (int i = 0; i < n; ++i) { cout << 0 << " "; } cout << "\n"; return; } int j = 0; ll curr = 0; int curr_edge_len = 0; for (int i = 0; i < n; ++i) { while (curr < c) { curr += d[j]; j += 1; ++curr_edge_len; if (j == n) j = 0; } nextt[0][i] = j; edge_len[0][i] = curr_edge_len; --curr_edge_len; curr -= d[i]; } for (int k = 1; k < LOGG; ++k) { for (int i = 0; i < n; ++i) { nextt[k][i] = nextt[k - 1][nextt[k - 1][i]]; edge_len[k][i] = edge_len[k - 1][i] + edge_len[k - 1][nextt[k - 1][i]]; } } for (int i = 0; i < n; ++i) { int ans = -1; ll left = n; int curr = i; for (int k = LOGG - 1; k >= 0; --k) { //cout << edge_len[k][curr] << "\n"; if (left >= edge_len[k][curr]) { left -= edge_len[k][curr]; ans += (1 << k); curr = nextt[k][curr]; } } if (left > 0) ++ans; cout << ans << " "; } cout << "\n"; } // g++ -DLC -o a a.cpp && ./a