#include <bits/stdc++.h>
using namespace std;
std::vector<long long> a;
long long sm = 0;
long long n, m;
bool doo(long long x) {
  long long res = 0;
  for (long long i = 0; i < x; ++i) {
    res += a[i];
    long long k = i + x;
    long long count = 1;
    while (k < n and a[k] - count > 0) {
      res += max(0ll, a[k] - count);
      k += x;
      count++;
    }
  }
  return res >= m;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> m;
  (a).clear(), (a).resize(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    sm += a[i];
  }
  sort((a).rbegin(), (a).rend());
  if (sm < m) {
    cout << "-1";
    exit(0);
  }
  long long l = 1, h = n + 1;
  long long mid;
  long long ans = -1;
  while (l <= h) {
    mid = (l + h) / 2;
    if (doo(mid)) {
      ans = mid;
      h = mid - 1;
    } else
      l = mid + 1;
  }
  cout << ans << '\n';
  return 0;
}
