#include <bits/stdc++.h>
using namespace std;
long long int s[500020];
long long int q[500020];
long long int n, m;
long long int check(long long int st, long long int ed, long long int mi) {
  long long int acc = 0;
  if (s[ed] > mi) return q[ed] - q[st] - (ed - st) * mi;
  for (long long int i = st + 1; i <= ed; i++) {
    if (s[i] > mi) {
      acc += s[i] - mi;
    }
  }
  return acc;
}
bool go(long long int d) {
  if (d >= n) {
    return q[n] >= m;
  }
  if (!d) return m == 0;
  long long int sum = 0;
  long long int idx = 0;
  long long int i = 0;
  while (sum < m) {
    if (idx + d > n) {
      sum += check(idx, n, i);
      if (sum < m)
        return false;
      else
        return true;
    } else {
      sum += check(idx, idx + d, i);
    }
    idx += d;
    i++;
  }
  return true;
}
int main() {
  scanf(
      "%lld"
      "%lld",
      &n, &m);
  for (long long int i = 1; i <= n; i++) scanf("%lld", &s[i]);
  q[0] = 0;
  sort(s + 1, s + n + 1, greater<long long int>());
  for (long long int i = 1; i <= n; i++) {
    q[i] = s[i];
    if (i > 1) q[i] += q[i - 1];
  }
  long long int ans = -1, l, r, mid;
  l = 0;
  r = 1e9;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (go(mid)) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  printf(
      "%lld"
      "\n",
      ans);
  return 0;
}
