#include #include #include #include #include using namespace std; typedef unsigned long long ull; const ull MOD = 1000000007; ull cal(int n) { ull sum=0; for(int k=0; k &vi) { int t = vi[0]; ull ans=1; int i=0,lastIdx=0; for(; ivi[i+1]) { ans*=cal(i+1-lastIdx); lastIdx = i+1; ans%=MOD; } t=vi[i]; } ans*=cal(vi.size()-1-lastIdx+1); ans%=MOD; return ans; } int main() { int n; cin>>n; vector vi(n,0); for(int i=0; i>vi[i]; } cout<