#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long a[N], b[N];
long long n, m;
bool check(int x) {
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % x == 0)
      ans += max(b[i] - i / x + 1, (long long)0);
    else
      ans += max(b[i] - i / x, (long long)0);
  }
  if (ans >= m) return true;
  return false;
}
int main() {
  scanf("%lld%lld", &n, &m);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum += a[i];
  }
  if (sum < m) {
    printf("-1\n");
    return 0;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) b[i] = a[n - i + 1];
  int l, r, mid;
  l = 1, r = n + 1;
  while (l < r) {
    mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d\n", l);
  return 0;
}
