#include <bits/stdc++.h>
using namespace std;
const long long MAX = 3e5;
long long a[MAX];
long long n, m;
bool check(long long days) {
  long long sum = 0;
  long long i = 0;
  long long quitar = 0;
  while (i < n) {
    long long k = 0;
    while (i < n && k < days) {
      sum += max(a[i] - quitar, 0LL);
      i++;
      k++;
    }
    quitar++;
  }
  return sum >= m;
}
long long search(long long ini, long long fin) {
  if (!check(fin)) return -1;
  if (check(ini)) return ini;
  while (fin - ini > 1) {
    long long med = (ini + fin) / 2;
    if (check(med)) {
      fin = med;
    } else {
      ini = med;
    }
  }
  return fin;
}
bool cmp(const long long &x, const long long &y) { return x > y; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  long long sum = 0;
  for (long long i = 0; i < (long long)n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum < m) {
    cout << -1 << endl;
    return 0;
  }
  sort(a, a + n, cmp);
  cout << search(1, n) << endl;
  return 0;
}
