#include <bits/stdc++.h>
using namespace std;
long long n, m, arr[200005];
long long fx(long long days) {
  long long sum = 0;
  long long fact = 0;
  for (long long i = 0; i < n; i++) {
    sum += max(0LL, arr[i] - fact);
    if (sum >= m) return 1;
    if ((i + 1) % days == 0) fact++;
  }
  return 0;
}
long long binary_search() {
  long long lo = 1;
  long long hi = n;
  long long ans = 0;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (fx(mid)) {
      ans = mid;
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  long long tot_sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    tot_sum += arr[i];
  }
  sort(arr, arr + n);
  if (tot_sum == m) {
    cout << n << endl;
  } else if (tot_sum > m) {
    long long res_1 = binary_search();
    reverse(arr, arr + n);
    long long res_2 = binary_search();
    cout << min(res_1, res_2) << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
