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