#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> vec;
long long check(long long x) {
  long long count = 0;
  for (long long i = 0; i < n; i++) {
    count += max((long long)0, vec[i] - i / x);
  }
  if (count >= m) return 1;
  return 0;
}
int main() {
  cin >> n >> m;
  long long r1 = n;
  long long sum = 0;
  while (r1--) {
    long long a;
    cin >> a;
    sum += a;
    vec.push_back(a);
  }
  if (sum < m)
    cout << -1 << endl;
  else {
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    if (check((long long)1) == 1)
      cout << 1 << endl;
    else {
      long long l = 1, r = n, mid;
      while (l <= r) {
        mid = (l + r) / 2;
        if (check(mid) == 1) {
          if (check(mid - 1) == 0)
            break;
          else
            r = mid - 1;
        } else
          l = mid + 1;
      }
      cout << mid << endl;
    }
  }
}
