#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
using namespace std;
const int stalin = 1000000000 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector <int> dziury(n + 1);
long long il = 1;
for (int i = 1; i <= n; i++) {
cin >> dziury[i];
}
sort(dziury.begin(), dziury.end());
int k = 0, q = 0;
for (int i = n; i > 0; i--) {
while (n - k > 0 && i <= dziury[n - k]) {
k++;
}
il *= k - q;
il %= stalin;
q++;
}
cout << il;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8bWFwPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBzdGFsaW4gPSAxMDAwMDAwMDAwICsgNzsKCmludCBtYWluKCkgewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKCWNpbi50aWUoMCk7Cgljb3V0LnRpZSgwKTsKCglpbnQgbjsKCWNpbiA+PiBuOwoJdmVjdG9yIDxpbnQ+IGR6aXVyeShuICsgMSk7Cglsb25nIGxvbmcgaWwgPSAxOwoKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewoJCWNpbiA+PiBkeml1cnlbaV07Cgl9CgoJc29ydChkeml1cnkuYmVnaW4oKSwgZHppdXJ5LmVuZCgpKTsKCglpbnQgayA9IDAsIHEgPSAwOwoKCWZvciAoaW50IGkgPSBuOyBpID4gMDsgaS0tKSB7CgkJd2hpbGUgKG4gLSBrID4gMCAmJiBpIDw9IGR6aXVyeVtuIC0ga10pIHsKCQkJaysrOwoJCX0KCQlpbCAqPSBrIC0gcTsKCQlpbCAlPSBzdGFsaW47CgkJcSsrOwoJfQoKCWNvdXQgPDwgaWw7Cn0=