#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
long long int t, n, m, j, ans, k, a, b, c, d, e, f, sum, i, lo, hi, mid;
string s, s2, s3, s4;
long long int ar[(int)(1e6 + 10)];
vector<long long int> v;
void brainfuck();
bool calll(long long int xx);
int main() {
  brainfuck();
  return 0;
}
void brainfuck() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a;
    v.push_back(a);
    sum += a;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  a = sum - m;
  if (a < 0) {
    cout << "-1";
    return;
  }
  if (sum == m) {
    cout << n;
    return;
  }
  lo = 0;
  hi = n - 1;
  ans = INT_MAX;
  if (lo == hi && v[0] >= m) {
    cout << n;
    return;
  }
  while (lo < hi) {
    mid = (lo + hi) / 2;
    if (calll(mid)) {
      ans = min(ans, mid + 1);
      hi = mid;
    } else
      lo = mid + 1;
  }
  cout << ans;
}
bool calll(long long int xx) {
  a = 0;
  for (i = 0; i <= xx; i++) {
    a += v[i];
  }
  b = m - a;
  c = 1;
  e = f = 0;
  for (i = xx + 1; i < n; i++) {
    if (e + 1 <= xx + 1) {
      e++;
    } else {
      e = 1;
      c++;
    }
    k = (long long int)v[i] - c;
    f += max((long long int)0, k);
    if (f >= b) return 1;
  }
  if (f >= b) return 1;
  return 0;
}
