#include <bits/stdc++.h>
using namespace std;
bool br1, br2, br;
long long n, k, x, y, z, mini, maxi, w, l, ind, ini, sum, t, len, r, q, m,
    imini;
long long a[(int)2e5 + 100];
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (long long i = 0; i < n; i++) {
    z = 0;
    if (sum - a[i] < m) {
      x = m - (sum - a[i]);
      z += x - 1;
    }
    if (n - 1 < m) {
      y = min(m - n + 1, a[i]);
      z += a[i] - y;
    }
    cout << min(z, a[i]) << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
