#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

const int mod = 1e9 + 7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod - 2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    sort(rall(a));
    a.push_back(0);
    mint ans = 1;
    rep(i,a.size()-1) {
        ans *= a[i] - a[i + 1] + 1;
    }
    cout << ans << endl;
}
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int lli;


int A,B,W;

int main()
{
    string s;
    cin >> s;
    long long x = std::stoll(s);
    int digit;
    int L = s.size();
    long long int cnt = (L-1) / 3;


    long long int sum =(long long int)cnt* x;
    for (int j=cnt;j>=1;j--)
    {

        long long int l = 1;
        for (int i=1;i<=j;i++)
        {
            l *= 1000;
        }
        l--;

        sum -=  l;
    }
    printf("%lld\n", sum);
    return 0;
}
