#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[200100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long l = 1, r = 2e9, mid, ans = 2e9;
  while (l <= r) {
    mid = (l + r) / 2;
    long long h = -1;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      if (i % mid == 0) h++;
      sum += max(a[i] - h, 0LL);
    }
    long long br = 0, pom = 0;
    h = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (br % mid == 0) h++;
      pom += max(a[i] - h, 0LL);
      br++;
    }
    sum = max(sum, pom);
    if (sum >= m) {
      ans = min(ans, mid);
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  if (ans == 2e9) ans = -1;
  cout << ans;
  return 0;
}
