#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans, c, p;
  cin >> N;
  ans = 0;
  vector<long long> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  c = N;
  sort(b.begin(), b.end());
  for (int i = 0; i < N; i++) {
    if (c >= b[i]) {
      c -= b[i];
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
}
