#include <bits/stdc++.h>
using namespace std;
long long a[200010], n, m;
int check(long long x) {
  long long p = n / x, q = n % x, w = x - q, s = 0;
  long long b[200010];
  long long i, j;
  for (i = 1; i <= q; i++) b[i] = p;
  j = q + 1;
  for (i = p - 1; i >= 0; i--) {
    for (int k = 0; k < x; k++) b[j + k] = i;
    j += x;
  }
  for (i = 1; i <= n; i++) {
    s += max((long long)0, a[i] - b[i]);
  }
  if (s >= m)
    return 1;
  else
    return 0;
}
int main() {
  int i, j, k;
  long long x, l, r, mid;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  l = 1;
  r = n;
  while (l != r) {
    mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (check(r))
    cout << r << endl;
  else
    cout << -1 << endl;
  return 0;
}
