#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
bool cmp(long long int &a, long long int &b) { return (a > b); }
int main() {
  long long int i, j, k, l, m, n, tc, x, y, z;
  long long int ar[1000001];
  vector<long long int> v;
  string s;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n, cmp);
  long long int r = n;
  l = 1;
  while (l < (r - 1)) {
    long long int sum = 0;
    long long int c = 0;
    long long int mid = (l + r) / 2;
    for (j = 0; j < n; j++) {
      sum += max(ar[j] - j / mid, c);
    }
    if (sum >= m) {
      r = mid;
    } else {
      l = mid;
    }
  }
  long long int sum = 0;
  long long int c = 0;
  for (j = 0; j < n; j++) {
    sum += max(ar[j] - j / l, c);
  }
  if (sum >= m) {
    cout << l;
    return 0;
  }
  sum = 0;
  for (j = 0; j < n; j++) {
    sum += max(ar[j] - j / r, c);
  }
  if (sum >= m) {
    cout << r;
  } else
    cout << -1;
  return 0;
}
