#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, l, m, n, p = 0, cnt = 0, mini, maxi = 0, w, x, y, z,
                                  cnt1 = 0, x1, y1, a, b, i1 = 0, ans;
  cin >> n >> m;
  vector<long long int> V;
  long long int A[n];
  long long int sum[n];
  for (i = 0; i < n; i++) {
    cin >> A[i];
    cnt += A[i];
  }
  if (cnt < m) {
    cout << -1 << endl;
  } else {
    sort(A, A + n, greater<long long int>());
    sum[0] = A[0];
    for (i = 1; i < n; i++) {
      sum[i] = sum[i - 1] + A[i];
    }
    long long int mid, low, high, x;
    low = 1;
    high = n;
    x = n;
    while (low <= high) {
      mid = (low + high) / 2;
      ans = sum[mid - 1];
      p = 0;
      l = 0;
      for (j = mid; j < n; j++) {
        if (l % mid == 0) p++;
        ans = ans + max(0ll, A[j] - p);
        l++;
      }
      if (ans >= m) {
        x = min(x, mid);
        high = (mid - 1);
      } else {
        low = mid + 1;
      }
    }
    cout << x << endl;
  }
}
