#include <bits/stdc++.h>
using namespace std;
const long long M = 2e5 + 10;
long long v[M], a[M];
bool cmp(long long x, long long y) { return x > y; }
int main() {
  long long n, m, cnt = 0, ans = 0;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  if (ans < m) {
    cout << -1 << endl;
    return 0;
  }
  long long en = n;
  sort(a + 1, a + n + 1, cmp);
  long long l = 1, r = n;
  while (l < r) {
    long long mid = (l + r) >> 1;
    long long num = n / mid;
    for (long long i = 0; i <= num - 1; i++) {
      for (long long j = 1; j <= mid; j++) {
        v[++cnt] = i;
      }
    }
    for (long long i = 1; i <= (n % mid); i++) v[++cnt] = num;
    sort(v + 1, v + 1 + cnt);
    long long kk = 0;
    for (long long i = 1; i <= cnt; i++) {
      kk += max(0 * 1LL, a[i] - v[i]);
    }
    for (long long i = 1; i <= cnt; i++) v[i] = 0;
    cnt = 0;
    if (kk >= m)
      r = mid, en = mid;
    else
      l = mid + 1;
  }
  cout << en << endl;
}
