#include <bits/stdc++.h>
//#include <atcoder/all>
#include <unordered_map>

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
using VV = vector<V>;
using SV = vector<string>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }

// 素数判定
bool is_prime(ll n) {
	if (n == 1) return false;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

void solve_abc_c() {
	ll n, m;
	ll k;
	ll h, w;
	//ll x, y;
	//ll a, b, c;
	ll t;
	string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;

	cin >> n;

	ll prev = 1000;
	ll next = 1000000;
	ll x = 1;
	if (n > 999) {
		while (1) {
			if (n < next) {
				l_ans += (n - prev + 1) * x;
				break;
			}
			l_ans += (next - prev) * x;
			prev = next;
			next *= 1000;
			x++;
		}
	}

	cout << l_ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_c();

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define sp     ' '
#define endl   '\n'
#define F      first
#define S      second
#define mp     make_pair
#define pb     push_back
#define mt     make_tuple
#define PI     (2 * acos(0))
#define all(x) x.begin(), x.end()
#define spc(x) cout<<fixed<<setprecision(x)

void solve()
{
    long long t,m,n,a,b,c,d,g,i,j,k,x,y,z,cnt=1,cnt1=0;
    bool flag= false; string s,s1;
	
    cin >> n ;
    set<long long>st;
    for(i=0;i<n;i++)
    {
    	cin >> x ;
    	st.insert(x);
    }
    for(long long ss : st)
    {
    	ss++;

    	cnt *= ss-cnt1;
    	cnt1 = ss-1 ;

    	cnt = cnt%1000000007;
    }
    cout << cnt << endl ;
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)

    solve();

    return 0;
}