#include <bits/stdc++.h>
using namespace std;
long long int fact(long long int n) {
  if (n == 0 || n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
long long power(long long int base, long long int exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % 998244353;
    base = (base * base) % 998244353;
    exp /= 2;
  }
  return res % 998244353;
}
long long n;
long long b(long long l, long long r, long long a[], long long m) {
  long long mid;
  while (l < r) {
    mid = (l + r) / 2;
    long long cnt = mid;
    long long sum = 0;
    long long s = 0;
    for (long long i = n - 1; i >= 0; i--) {
      sum += max(a[i] - s, (long long)0);
      cnt--;
      if (cnt == 0) {
        s++;
        cnt = mid;
      }
    }
    if (sum == m)
      return mid;
    else if (sum < m)
      l = mid + 1;
    else
      r = mid;
  }
  return r;
}
long long solve() {
  long long m;
  cin >> n >> m;
  long long a[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  if (sum < m) {
    cout << "-1";
    return 0;
  } else
    cout << b(1, n, a, m);
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
