#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7, M = 2e6;
const long long mod = 1e9 + 7;
inline int read() {
  int ret = 0;
  char ch = getchar();
  bool f = 1;
  for (; !isdigit(ch); ch = getchar()) f ^= !(ch ^ '-');
  for (; isdigit(ch); ch = getchar()) ret = (ret << 1) + (ret << 3) + ch - 48;
  return f ? ret : -ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
long long a[N];
long long Max(long long x, long long y) {
  if (x < y) return y;
  return x;
}
int main() {
  long long n, m;
  long long sum = 0;
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum += a[i];
  }
  if (sum < m) {
    puts("-1");
    return 0;
  }
  sort(a + 1, a + 1 + n);
  long long l = 1, r = n;
  while (l < r) {
    int mi = (l + r) / 2;
    long long res = 0;
    for (int i = 1; i <= n; i++) {
      res += Max(0, a[i] - (n - i) / mi);
    }
    if (res >= m)
      r = mi;
    else
      l = mi + 1;
  }
  printf("%lld\n", r);
  return 0;
}
