#include <bits/stdc++.h>
using namespace std;
const long long int N = 400005;
const long long int LG = 22;
long long int day(long long int x, long long int y) {
  if (x % y) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  long long int a[n], pre[n];
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n, greater<long long int>());
  long long int res = sum - m;
  memset(pre, 0, sizeof(pre));
  pre[0] = a[0];
  for (long long int i = 1; i < n; i++) {
    pre[i] = a[i] + pre[i - 1];
  }
  if (sum < m) {
    cout << -1;
    return 0;
  }
  long long int ans = 0;
  long long int lo = 1, hi = n;
  while (lo <= hi) {
    long long int mid = (lo + hi) >> 1;
    long long int sum = 0;
    long long int lol = 0, c = 0, neg = 0;
    for (long long int i = 0; i < n; i++) {
      sum += max(0LL, a[i] - neg);
      c++;
      if (c == mid) neg++, c = 0;
    }
    if (sum >= m) {
      ans = mid;
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  cout << ans;
  return 0;
}
