#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long M = 1000000007;
vector<vector<long long> > v;
long long A[2 * N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, sum = 0;
  cin >> n >> m;
  long long A[n];
  for (long long i = 0; i < n; i++) cin >> A[i], sum += A[i];
  sort(A, A + n, greater<long long>());
  if (sum < m)
    cout << -1 << endl;
  else {
    long long l = 1, r = n;
    long long mid;
    while (l != r) {
      mid = (l + r) / 2;
      sum = 0;
      for (long long i = 0; i < n; i++) {
        sum += max(A[i] - (i / mid), 0ll);
      }
      if (sum >= m)
        r = mid;
      else
        l = mid + 1;
    }
    cout << l << endl;
  }
  return 0;
}
