#include <bits/stdc++.h>
using namespace std;
const long long N = 300000;
long long a[N], sum, b[N];
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, i, k, x = 0, mid, start, end, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n, greater<long long>());
  start = 1;
  end = n;
  while (start <= end) {
    mid = (start + end) / 2;
    i = mid;
    k = 0;
    for (j = 0; j < n; j++) k += max((long long)0, a[j] - j / i);
    if (k >= m) {
      b[x] = i;
      x++;
      end = mid - 1;
    } else
      start = mid + 1;
  }
  if (x == 0)
    cout << -1 << endl;
  else {
    sort(b, b + x);
    cout << b[0] << endl;
  }
  return 0;
}
