#include <bits/stdc++.h>
using namespace std;
long long a[1000000];
int cmp(long long aa, long long bb) { return aa > bb; }
int check(long long k, long long mm, long long nn) {
  long long sum = 0;
  for (int i = 0; i < nn; i++) {
    sum += max(a[i] - i / k, 0ll);
  }
  return sum >= mm;
}
int main() {
  long long n, m;
  while (scanf("%lld%lld", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
    }
    int flag = 0;
    sort(a, a + n, cmp);
    long long l = 1, r = n, ans = 0x3f3f3f3f;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      if (check(mid, m, n)) {
        r = mid - 1;
        ans = min(ans, mid);
      } else
        l = mid + 1;
    }
    if (ans != 0x3f3f3f3f)
      printf("%lld\n", ans);
    else
      printf("-1\n");
  }
  return 0;
}
