#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1, greater<long long>());
  bool is = false;
  long long st = 1, sec = 1000000001;
  long long sum;
  while (st < sec) {
    long long mid = (st + sec) / 2;
    sum = 0;
    for (long long i = 1; i <= n; i++)
      sum += max((long long)0, a[i] - (i - 1) / mid);
    if (sum >= m) {
      sec = mid;
    } else {
      st = mid + 1;
    }
  }
  if (st <= 1000000000)
    cout << st << endl;
  else
    cout << "-1\n";
  return 0;
}
