#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
  cin >> n;
  long long m;
  cin >> m;
  long long a[n];
  long long ggg = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    ggg += a[i];
  }
  if (ggg < m) {
    cout << -1;
    exit(0);
  }
  sort(a, a + n, greater<long long>());
  long long l = 0, r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    long long b[mid];
    memset(b, 0, sizeof(b));
    long long sum = 0;
    for (long long i = 0; i < n; ++i) {
      b[i % mid] += a[i] - i / mid;
      if (a[i] - i / mid > 0) {
        sum += a[i] - i / mid;
      }
    }
    if (sum >= m) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
}
