#include #define mod 10000000007 using namespace std; vector numbers; vector factDp; void fillFact(){ factDp.push_back(1); for(int i = 1 ; i <= 1200 ; i++){ long long tmp = factDp[factDp.size()-1]; factDp.push_back((tmp*i)%mod); } } long long power(long long base , long long up){ if(up == 0) return 1; long long tmp = power(base,up/2)%mod; if(up%2){ return ((tmp * tmp)%mod * (base%mod))%mod ; }else{ return (tmp * tmp)%mod; } } int main() { int n , m , total; total = 1; cin >> n ; numbers.resize(n); fillFact(); for(int i = 0 ; i < n ; i++){ cin >> numbers[i]; } for(int i = 1 ; i < n ; i++){ if(numbers[i] > numbers[i-1]){ total++; }else{ break; } } long long res = 2; if(total > 2){ for(int i = 2 ; i <= total ; i++){ res+= power(factDp[i],(total/2-1)) * factDp[total%i]; res%=mod; } cout << res ; }else{ cout << total; } return 0; }