#include <bits/stdc++.h>
using namespace std;
long long b[200010], ans[200010];
int main() {
  long long n, A, a, c, tot;
  while (cin >> n >> A) {
    tot = 0;
    for (int i = 1; i <= n; i++) {
      cin >> b[i];
      tot += b[i];
    }
    if (n > A || tot < A) {
      for (int i = 1; i <= n; i++) {
        if (i != 1) cout << " ";
        cout << b[i];
      }
      cout << endl;
    } else {
      for (int i = 1; i <= n; i++) {
        ans[i] = 0;
        a = tot - b[i];
        c = n - 1;
        if (c >= A || a + b[i] < A)
          ans[i] = b[i];
        else {
          if (A >= a) {
            if (c + b[i] > A) ans[i] += c + b[i] - A;
            if (a + b[i] < A) ans[i] += b[i];
            if (a + b[i] >= A && A - a - 1 > 0) {
              ans[i] += A - a - 1;
            }
          } else {
            if (c + b[i] <= A)
              ans[i] = 0;
            else {
              ans[i] += c + b[i] - A;
            }
          }
        }
      }
      for (int i = 1; i <= n; i++) {
        if (i != 1) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    }
  }
  return 0;
}
