#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int ar[n];
  for (long long int &i : ar) cin >> i;
  sort(ar, ar + n);
  reverse(ar, ar + n);
  long long int start = 1, end = n;
  long long int f = INT_MAX;
  while (start <= end) {
    long long int mid = (start + end) / 2;
    long long int sum = 0;
    for (int i = 0; i < n; ++i) {
      long long int zero = 0;
      sum += max(zero, ar[i] - i / mid);
    }
    if (sum >= m) {
      f = min(f, mid);
      end = mid - 1;
    } else if (sum < m)
      start = mid + 1;
  }
  if (f <= n)
    cout << f << endl;
  else
    cout << -1 << endl;
}
