#include <bits/stdc++.h>
using namespace std;
const int len = 100004;
const int LEN = 1003005;
void integer_scan(int &n) {
  int sign = 1;
  n = 0;
  char c = getchar_unlocked();
  while (c < '0' || c > '9') {
    if (c == '-') sign = -1;
    c = getchar_unlocked();
  }
  while (c >= '0' && c <= '9')
    n = (n << 3) + (n << 1) + c - '0', c = getchar_unlocked();
  n = n * sign;
}
void long_integer_scan(long long int &n) {
  int sign = 1;
  n = 0;
  char c = getchar_unlocked();
  while (c < '0' || c > '9') {
    if (c == '-') sign = -1;
    c = getchar_unlocked();
  }
  while (c >= '0' && c <= '9')
    n = (n << 3) + (n << 1) + c - '0', c = getchar_unlocked();
  n = n * (long long int)(sign);
}
int string_scan(char a[]) {
  char c = getchar_unlocked();
  while (c == ' ' || c == '\n') c = getchar_unlocked();
  int i = 0;
  while (c != '\n') a[i++] = c, c = getchar_unlocked();
  a[i] = 0;
  return i;
}
int word_scan(char a[]) {
  char c = getchar_unlocked();
  while (c == ' ' || c == '\n') c = getchar_unlocked();
  int i = 0;
  while (c != '\n' && c != ' ') a[i++] = c, c = getchar_unlocked();
  a[i] = 0;
  return i;
}
void integer_print(int n) {
  if (n < 0) {
    n = -n;
    putchar_unlocked('-');
  }
  int i = 10;
  char o[10];
  do {
    o[--i] = (n % 10) + '0';
    n /= 10;
  } while (n);
  do {
    putchar_unlocked(o[i]);
  } while (++i < 10);
}
void long_integer_print(long long int n) {
  if (n < 0LL) {
    n = -n;
    putchar_unlocked('-');
  }
  int i = 21;
  char o[21];
  do {
    o[--i] = (n % 10LL) + '0';
    n /= 10LL;
  } while (n);
  do {
    putchar_unlocked(o[i]);
  } while (++i < 21);
}
void string_print(const char a[]) {
  const char *p = a;
  while (*p) putchar_unlocked(*p++);
}
int isprime(long long int n) {
  if (n == 1 || n == 0 || n == 10 || n == 4 || n == 6 || n == 8)
    return 0;
  else if (n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13)
    return 1;
  long long int limit = sqrt(n);
  for (int i = 2; i < limit + 1; i++)
    if (n % i == 0) return 0;
  return 1;
}
long long int get_sum(long long int a[len], int n) {
  long long int sum = a[0];
  for (int i = 1; i < n; i++) sum += a[i];
  return sum;
}
long long int d[2 * len], sum, done[1000006] = {0}, n, ones = 0, cant,
                               array_sum = 0;
int main() {
  long_integer_scan(n);
  long_integer_scan(sum);
  for (int i = 0; i < n; i++) {
    long_integer_scan(d[i]);
    if (d[i] == 1) ++ones;
    array_sum += d[i];
  }
  if (n == 1) {
    cout << d[0] - 1 << endl;
    return 0;
  }
  if (array_sum == sum) {
    for (int i = 0; i < n; i++) cout << d[i] - 1 << " ";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (done[d[i]]) {
      cout << done[d[i]] << " ";
      continue;
    }
    if (d[i] == 1) {
      cant = 0;
      done[d[i]] = cant;
    } else {
      long long int remaining_sum = sum - ones;
      long long int remaining_dice = n - ones;
      long long int remaining_dice_sum = array_sum - ones - d[i];
      if (remaining_dice == remaining_sum) {
        cant = d[i] - 1;
      } else if (remaining_sum > remaining_dice) {
        if (remaining_sum >= d[i]) {
          if ((remaining_sum - d[i] >= remaining_dice - 1)) {
            cant = 0;
          } else if (remaining_sum - d[i] < remaining_dice - 1) {
            long long int max_i_can_take = remaining_sum - (remaining_dice - 1);
            cant = d[i] - max_i_can_take;
          }
        } else {
          long long int max_i_can_take = remaining_sum - (remaining_dice - 1);
          cant = d[i] - max_i_can_take;
        }
      }
      done[d[i]] = cant;
      if (remaining_sum > array_sum - ones - d[i]) {
        long long int min_i_should_take =
            remaining_sum - (array_sum - ones - d[i]);
        done[d[i]] += min_i_should_take - 1;
      }
    }
    cout << done[d[i]] << " ";
  }
  return 0;
}
