#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> a(N);
  ll sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.rbegin(), a.rend());
  if (sum < M) {
    cout << -1 << endl;
    return 0;
  }
  ll high = N;
  ll low = 0;
  while (high - low > 1) {
    sum = 0;
    ll mid = (high + low) / 2;
    for (int i = 0; i < N; ++i) {
      sum += max(0LL, a[i] - (i / mid));
    }
    if (sum >= M) {
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << high << endl;
  return 0;
}
