#include <bits/stdc++.h>
using namespace std;
const int maxN = 200200;
int a[maxN];
int main() {
  int n;
  long long sum;
  scanf("%d", &n);
  scanf("%lld", &sum);
  for (int i = 0; i < (n); ++i) scanf("%d", &a[i]);
  long long allSum = 0;
  for (int i = 0; i < (n); ++i) allSum += a[i];
  for (int i = 0; i < (n); ++i) {
    long long restMax = allSum - a[i];
    long long restMin = n - 1;
    int l = 1, r = a[i];
    while (l < r) {
      int m = (l + r) >> 1;
      long long leftSum = sum - m;
      if (leftSum > restMax)
        l = m + 1;
      else
        r = m;
    }
    int curMin = l;
    l = 1, r = a[i];
    while (l < r) {
      int m = (l + r + 1) >> 1;
      long long leftSum = sum - m;
      if (leftSum < restMin)
        r = m - 1;
      else
        l = m;
    }
    int curMax = l;
    assert(curMin <= curMax);
    printf("%d ", a[i] - (curMax - curMin + 1));
  }
  printf("\n");
  return 0;
}
