#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a;
bool can(int p) {
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += max(0, a[i] - i / p);
  }
  return sum >= m;
}
int main() {
  cin >> n >> m;
  a = vector<int>(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r) / 2;
    if (can(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (can(l))
    cout << l << endl;
  else if (can(r))
    cout << r << endl;
  else
    cout << -1 << endl;
  return 0;
}
