#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n, 0);
  long long int i, sum = 0;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  if (sum < m) {
    cout << -1 << "\n";
  } else {
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    long long int l = 1, r = n;
    long long int ans = n;
    long long int mid;
    long long int sum2, temp, count;
    while (l <= r) {
      mid = l + (r - l) / 2;
      sum2 = 0;
      temp = 0;
      count = 0;
      for (i = 0; i < n; i++) {
        sum2 += max(0LL, (v[i] - temp));
        count++;
        if (count == mid) {
          temp++;
          count = 0;
        }
      }
      if (sum2 >= m) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << "\n";
  }
}
