#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

static const LL MODVAL = 1000000007;
class RabbitNumbering { public:
	int theCount(vector <int> maxNumber) 
	{
		sort(maxNumber.begin(), maxNumber.end());
		LL c = 1;
		for(int i=0; i<maxNumber.size(); ++i)
			if( maxNumber[i]-i <= 0 )
				return 0;
			else
				c = (c * (maxNumber[i]-i)) % MODVAL;
		return c;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, RabbitNumbering().theCount(maxNumber));}
int main(){

CASE(0)
	int maxNumber_[] = {5};
	  vector <int> maxNumber(maxNumber_, maxNumber_+sizeof(maxNumber_)/sizeof(*maxNumber_)); 
	int _ = 5; 
END
CASE(1)
	int maxNumber_[] = {4, 4, 4, 4};
	  vector <int> maxNumber(maxNumber_, maxNumber_+sizeof(maxNumber_)/sizeof(*maxNumber_)); 
	int _ = 24; 
END
CASE(2)
	int maxNumber_[] = {5, 8};
	  vector <int> maxNumber(maxNumber_, maxNumber_+sizeof(maxNumber_)/sizeof(*maxNumber_)); 
	int _ = 35; 
END
CASE(3)
	int maxNumber_[] = {2, 1, 2};
	  vector <int> maxNumber(maxNumber_, maxNumber_+sizeof(maxNumber_)/sizeof(*maxNumber_)); 
	int _ = 0; 
END
CASE(4)
	int maxNumber_[] = {25, 489, 76, 98, 704, 98, 768, 39, 697, 8, 56, 74, 36, 95, 87, 2, 968, 4, 920, 54, 873, 90};
	  vector <int> maxNumber(maxNumber_, maxNumber_+sizeof(maxNumber_)/sizeof(*maxNumber_)); 
	int _ = 676780400; 
END

}
// END CUT HERE
