#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long arr[n];
  long long s = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    s += arr[i];
  }
  if (s < m) {
    cout << -1;
    return 0;
  }
  sort(arr, arr + n);
  reverse(arr, arr + n);
  long long l = 1;
  long long r = n;
  while (l < r) {
    long long g = (l + r) / 2;
    long long k = 0;
    long long d = 0;
    long long c = 0;
    for (long long j = 0; j < n; j++) {
      k += max(0LL, arr[j] - c);
      d++;
      if (d == g) {
        d = 0;
        c++;
      }
    }
    if (k >= m) {
      r = (l + r) / 2;
    } else {
      l = (l + r) / 2;
      l++;
    }
  }
  cout << l;
  return 0;
}
