#include <bits/stdc++.h>
const long long INF = 1e18;
const long long mx = -1e9;
const long long mn = 1e9;
const long long mv = 2e5 + 5;
const double pi = 3.1415926535;
using namespace std;
long long n, m, a[mv], s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
  }
  if (s < m) {
    cout << "-1";
    return 0;
  }
  sort(a, a + n + 1);
  long long l = 1, r = m, m1;
  while (r - l > 1) {
    m1 = (r + l) / 2;
    long long s = 0;
    for (int j = n; j >= 1; j--) {
      s += max(0ll, a[j] - ((n - j + 1) / m1 + ((n - j + 1) % m1 != 0) - 1));
    }
    if (s >= m) {
      long long s1 = 0;
      if (m1 == 1 || m1 == m) {
        cout << m1;
        return 0;
      }
      for (int j = n; j >= 1; j--) {
        s1 += max(0ll, a[j] - ((n - j + 1) / (m1 - 1) +
                               ((n - j + 1) % (m1 - 1) != 0) - 1));
      }
      if (s1 < m) {
        cout << m1;
        return 0;
      }
      r = m1;
    } else {
      l = m1;
    }
  }
  s = 0;
  for (int j = n; j >= 1; j--) {
    s += max(0ll, a[j] - ((n - j + 1) / l + ((n - j + 1) % l != 0) - 1));
  }
  long long s1 = 0;
  for (int j = n; j >= 1; j--) {
    s += max(0ll, a[j] - ((n - j + 1) / r + ((n - j + 1) % r != 0) - 1));
  }
  if (s1 < m && s < m) {
    cout << "-1";
  } else {
    if (s >= m) {
      cout << l;
    } else {
      cout << r;
    }
  }
}
