#include <iostream>
#include <queue>
using namespace std;
using ll = long long;

int n;
priority_queue<ll> q;

void solve()
{
    q.push(0);
    ll res = 1, before = q.top(), now;
    q.pop();
    while (q.size() > 0)
    {
        now = q.top();
        q.pop();
        if (before > now)
        {
            res = res * (before - now + 1) % (1000000007);
            before = now;
        }
    }
    cout << res << '\n';
}

int main()
{
    ll qtemp;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        cin >> qtemp;
        q.push(qtemp);
    }

    solve();

    return 0;
}

#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)


int main() {
    ll n;
    cin >> n;
    ll tmp = 0, s = 0;
    while (s <= n + 1) {
        tmp++;
        s += tmp;
        if (s > n + 1)tmp -= 1;
    }
   
    ll ans = n - tmp + 1;
    cout << ans << endl;

    return 0;
}