#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
long long n, m;
bool isValid(long long mid) {
  long long sum = 0;
  for (long long i = 0; i < n; i++) sum += max(a[i] - i / mid, 0ll);
  return sum >= m;
}
void solve() {
  long long s = 0;
  cin >> n >> m;
  a.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  if (s < m) {
    cout << -1;
    return;
  }
  if (s == m) {
    cout << n;
    return;
  }
  sort(a.rbegin(), a.rend());
  long long e = n, mid;
  s = 1;
  while (s + 1 < e) {
    mid = (s + e) / 2;
    if (isValid(mid))
      e = mid;
    else
      s = mid;
  }
  if (isValid(s))
    cout << s << '\n';
  else if (isValid(e))
    cout << e << '\n';
  else
    cout << -1 << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
