#include <bits/stdc++.h>
using namespace std;
long long a[1000009];
int main() {
  long long n, m, i, j, ans = 2e18, lo, hi, mid, page = 0, p, p1;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  lo = 1;
  hi = n;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    i = 1;
    p = 0;
    page = 0;
    for (j = n; j >= 1; j--) {
      p1 = (a[j] - p);
      if (p1 < 0) p1 = 0;
      page += p1;
      i++;
      if (i > mid) {
        p++;
        i = 1;
      }
    }
    if (page > m) {
      hi = mid - 1;
      ans = min(ans, mid);
    } else if (page == m) {
      ans = min(ans, mid);
      break;
    } else
      lo = mid + 1;
  }
  if (ans != (2e18))
    cout << ans;
  else
    cout << "-1";
}
