#include <bits/stdc++.h>
using namespace std;
long long fn(vector<long long> v, long long day) {
  long long ret = 0, i, k = 0, p = 1;
  for (i = 0; i < v.size(); i++) {
    long long x = v[i];
    ret += max(x - k, (long long)0);
    p++;
    if (p > day) p = 1, k++;
  }
  return ret;
}
long long bs(vector<long long> v, long long m) {
  long long b = 1, e = v.size(), md;
  for (long long i = 1; i <= 64; i++) {
    md = ceil((double)(b + e) / 2.0);
    long long x = fn(v, md);
    if (x < m)
      b = md + 1;
    else if (x > m)
      e = md - 1;
  }
  return md;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long i;
  vector<long long> v;
  for (i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long ans = bs(v, m);
  if (ans > n)
    cout << "-1\n";
  else
    cout << ans << endl;
  return 0;
}
