#include <bits/stdc++.h>
using namespace std;
long long q, n, ta, tb, tc, f[500], a[300000], m;
bool can(long long days) {
  long long mm = m;
  for (long long i = 0, _i = (n); i < _i; ++i) {
    mm -= max((long long)0, a[i] - i / days);
    if (mm <= 0) return true;
  }
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0, _i = (n); i < _i; ++i) cin >> a[i];
  sort(a, a + n, greater<long long>());
  long long l = 1, r = n, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (can(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << (can(r) ? r : -1) << endl;
}
