#include <bits/stdc++.h>
using namespace std;
void nikal_pehli_fursat_mai() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  sort(v.rbegin(), v.rend());
  if (sum < m) {
    cout << -1 << "\n";
    return;
  }
  long long low = 1, high = n;
  for (int i = 0; i < 64; i++) {
    long long mid = (low + high) / 2;
    long long left = mid, pages = 0, penalty = 0;
    for (int i = 0; i < n and pages < m; i++) {
      if (left == 0) {
        left = mid;
        penalty++;
      }
      left--;
      pages += max(0LL, v[i] - penalty);
    }
    if (pages >= m) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  cout << low << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  while (tc--) {
    nikal_pehli_fursat_mai();
  }
}
