#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum < m) {
    cout << "-1\n";
    return 0;
  }
  sort(a, a + n);
  reverse(a, a + n);
  long long st = 1;
  long long end = n;
  long long ans = n;
  while (st <= end) {
    long long tmp = 0;
    long long mid = (st + end) / 2;
    long long cur = 0;
    for (long long i = 0; i < n; i++) {
      if (i >= (cur + 1) * mid) {
        cur++;
      }
      tmp += max(a[i] - cur, 0LL);
    }
    if (tmp >= m) {
      ans = mid;
      end = mid - 1;
    } else {
      st = mid + 1;
    }
  }
  cout << ans << "\n";
}
