#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v;
bool check(int k) {
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += max(0, v[i] - i / k);
  }
  return sum >= m;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  sort(v.begin(), v.end(), std::greater<int>());
  int l = 1, r = n;
  int mid;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (check(l))
    cout << l << endl;
  else if (check(r))
    cout << r << endl;
  else
    cout << "-1" << endl;
  return 0;
}
