#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n), b(n + 1, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    b[i + 1] = a[i] + b[i];
  }
  if (b[n] < m) {
    cout << -1 << endl;
    return 0;
  }
  long long left = 0;
  long long right = (long long)n;
  while (right - left > 1) {
    long long mid = (left + right) / 2;
    long long c = (long long)n;
    long long sum = 0;
    long long i = 0;
    while (c > 0) {
      long long p = (c - 1) / mid;
      long long q = ((c % mid == 0) ? mid : (c % mid));
      if (a[i] >= p) {
        sum += b[i + q] - b[i] - q * p;
      } else {
        if (a[i + q - 1] > p) {
          long long j = lower_bound(a.begin(), a.end(), p) - a.begin();
          sum += b[i + q] - b[j] - (i + q - j) * p;
        }
      }
      c -= q;
      i += q;
    }
    if (sum >= m)
      right = mid;
    else
      left = mid;
  }
  cout << right << endl;
  return 0;
}
