#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / GCD(a, b); }
const long long N = 2e5 + 7;
const long long inf = 1e18 + 1;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
long long n, m, a[N];
bool ck(long long x) {
  long long now = 0;
  for (int i = 1; i <= x; i++) now += a[i];
  int k = 1, ind = x + 1, cnt = 0;
  while (ind <= n && now < m) {
    now += max(0LL, a[ind] - k);
    ind++;
    cnt++;
    if (cnt >= x) cnt = 0, k++;
  }
  return now >= m;
}
int main() {
  cin >> n >> m;
  long long tot = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], tot += a[i];
  if (tot < m) {
    cout << "-1\n";
    return 0;
  }
  sort(a + 1, a + 1 + n, greater<long long>());
  long long l = 1, r = n;
  while (l < r) {
    long long mid = l + r >> 1;
    if (ck(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << "\n";
  return 0;
}
