#include <bits/stdc++.h>
using namespace std;
int arr[200000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> arr[i];
  sort(arr, arr + N, greater<int>());
  int lo = 0, hi = N + 1;
  while (lo + 1 < hi) {
    int mid = (lo + hi) / 2;
    long long e = 0;
    for (int i = 0; i < N; i++) e += max(0, arr[i] - i / mid);
    if (e < M)
      lo = mid;
    else
      hi = mid;
  }
  if (hi > N)
    cout << "-1\n";
  else
    cout << hi << '\n';
  return 0;
}
