#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
long long n;
long long a[200001], ans = -1;
long long m;
int cmp(int A, int b) { return A > b; }
int ch(int k) {
  int cnt = 0;
  long long sum = 0;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    sum += max(a[i] - cnt, 0ll);
    res++;
    if (res == k) cnt++, res = 0;
  }
  return sum >= m;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long sum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
  if (sum < m)
    return cout << -1, 0;
  else if (sum == m)
    return cout << n, 0;
  sort(a + 1, a + 1 + n, cmp);
  long long l = 1, r = n;
  ans = -1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (ch(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  cout << ans << endl;
  return 0;
}
