#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
long long n, m, a[200005], sum;
bool check(long long x) {
  long long bal = 0;
  long long c = 0;
  long long minus = 0;
  for (long long i = 1; i <= n; ++i) {
    bal += max((long long)0, a[i] - minus);
    ++c;
    if (c == x) ++minus, c = 0;
  }
  return bal >= m;
}
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) cin >> a[i], sum += a[i];
  if (sum < m) {
    cout << -1;
    return;
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  long long l = 0, r = n + 1;
  while (r - l > 1) {
    long long x = (l + r) / 2;
    if (check(x))
      r = x;
    else
      l = x;
  }
  cout << r;
}
