#include <bits/stdc++.h>
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
using namespace std;
const int maxn = 1e6 + 4;
int d[maxn], b[maxn];
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  long long sum = 0, A;
  scanf("%I64d", &A);
  for (int i = 0; i < n; i++) {
    scanf("%d", d + i);
    sum += d[i];
  }
  {
    for (int i = 0; i < n - 1; i++) {
      long long mx = A - (n - 1) > d[i] ? d[i] : A - (n - 1);
      long long mn = A - (sum - d[i]) > 1 ? A - (sum - d[i]) : 1;
      int ans = (d[i] - (mx - mn + 1)) > 0 ? (d[i] - (mx - mn + 1)) : 0;
      printf("%d ", ans);
    }
    long long mx = A - (n - 1) > d[n - 1] ? d[n - 1] : A - (n - 1);
    long long mn = A - (sum - d[n - 1]) > 1 ? A - (sum - d[n - 1]) : 1;
    int ans = (d[n - 1] - (mx - mn + 1)) > 0 ? (d[n - 1] - (mx - mn + 1)) : 0;
    printf("%d\n", ans);
  }
  return 0;
}
