#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  int n;
  long long m;
  cin >> n >> m;
  vector<int> coffees(n);
  long long dsum = 0;
  for (size_t i = 0; i < n; ++i) {
    cin >> coffees[i];
    dsum += coffees[i];
  }
  sort(begin(coffees), end(coffees), greater<int>());
  int l = 1;
  int r = n + 1;
  bool found = false;
  while (l < r) {
    int d = (l + r) / 2;
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      auto coffee = max(coffees[i] - i / d, 0);
      sum += coffee;
    }
    if (sum >= m) {
      r = d;
    } else {
      l = d + 1;
    }
  }
  if (l == n + 1) {
    cout << -1 << '\n';
  } else {
    cout << l << '\n';
  }
  return 0;
}
