#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    return b;
  }
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long int power(long long int x, long long int n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * x) % 1000000007;
    x = (x * x) % 1000000007;
    n /= 2;
  }
  if (x == 0) ans = 0;
  return ans;
}
long long int getsum(int g, int a[], int n, int x) {
  long long int i = n - 1, tmp = 0, k = g, count = 0;
  while (i >= 0) {
    while (k != 0 && i >= 0) {
      tmp += max((long long)0, (a[i] - count));
      i--;
      k--;
    }
    count++;
    k = g;
  }
  return tmp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, m, i;
    cin >> n >> m;
    int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int lo = 1, hi = n, mid;
    while (lo < hi) {
      mid = lo + (hi - lo) / 2;
      long long int tmp = getsum(mid, a, n, m);
      if (tmp < m) {
        lo = mid + 1;
      } else {
        hi = mid;
      }
    }
    if (getsum(lo, a, n, m) >= m) {
      cout << lo;
    } else {
      cout << -1;
    }
  }
}
