#include <bits/stdc++.h>
using namespace std;
long long f[400000], sum = 0;
int main() {
  long long n, m;
  long long l, r;
  long long k1, k2, ans;
  scanf("%I64d%I64d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &f[i]), sum += f[i];
  l = n - 1;
  for (int i = 1; i <= n; i++) {
    r = sum - f[i];
    k1 = m - r;
    k2 = m - l;
    if (k1 < 1) {
      if (k2 <= f[i])
        ans = k2;
      else
        ans = f[i];
    } else {
      if (k2 <= f[i])
        ans = k2 - k1 + 1;
      else
        ans = f[i] - k1 + 1;
    }
    ans = f[i] - ans;
    printf("%I64d ", ans);
  }
  printf("\n");
  return 0;
}
