#include <bits/stdc++.h>
const long long Inf = 1e18;
long long LINF = (long long)2e18;
using namespace std;
long long mod = 1e9 + 7;
long long mod3 = 998244353;
long long mod2 = 1e9 + 123;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  long long n, M;
  cin >> n >> M;
  vector<long long> a(n);
  long long sum = 0;
  for (int(i) = 0; (i) < n; (i)++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum < M) {
    cout << -1;
    return 0;
  }
  sort((a).rbegin(), (a).rend());
  int l = 1, r = n;
  while (l < r) {
    int m = (l + r) >> 1;
    long long sum = 0;
    for (int(i) = 0; (i) < n; (i)++) {
      long long dif = a[i] - i / m;
      sum += max(dif, (long long)0);
    }
    if (sum < M) {
      l = m + 1;
    } else
      r = m;
  }
  cout << l;
  return 0;
}
