#include <bits/stdc++.h>
using namespace std;
int a[200005];
long long mm(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int main() {
  int i, n;
  long long s = 0, s1;
  cin >> n >> s1;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s += a[i];
  }
  if (n == 1) {
    printf("%d\n", a[1] - 1);
    return 0;
  }
  for (i = 1; i <= n; i++) {
    long long x1, y1;
    x1 = mm(s1 - (s - a[i]), a[i]);
    if (x1 <= 0) x1 = 1;
    y1 = mm(a[i], s1 - (n - 1));
    printf("%d ", x1 - 1 + a[i] - y1);
  }
}
