#include <bits/stdc++.h>
using namespace std;
int n, m, p = 1000000;
bool checkDias(int a, const vector<unsigned long long int> &v) {
  for (int i = p; i < n + 1; i += 1) {
    unsigned long long int d = i / a;
    unsigned long long int r = i % a;
    if (v[i] >= (unsigned long long int)m + r * (d + 1) * d / 2 +
                    (a - r) * d * (d - 1) / 2)
      return true;
  }
  return false;
}
int main() {
  cin >> n >> m;
  vector<int> vect(n);
  vector<unsigned long long int> sumasparciales(n + 1, 0);
  for (int i = 0; i < n; i += 1) {
    cin >> vect[i];
  }
  sort(vect.begin(), vect.end(), greater<int>());
  for (int i = 0; i < n; i += 1) {
    sumasparciales[i + 1] = sumasparciales[i] + vect[i];
    if (sumasparciales[i + 1] >= m && i + 1 < p) p = i + 1;
  }
  if (sumasparciales[n] < m) {
    cout << -1 << endl;
    return 0;
  }
  int i = 1;
  int j = m;
  int minimo = m + 10;
  while (i <= j) {
    int nepe = (i + j) / 2;
    if (checkDias(nepe, sumasparciales)) {
      j = nepe - 1;
      minimo = min(minimo, nepe);
    } else
      i = nepe + 1;
  }
  cout << minimo << endl;
}
