//#define _GLIBCXX_DEBUG #include using namespace std; #define endl '\n' #define lfs cout<= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD1 = 1e9+7; const ll MOD9 = 998244353; const ll INF = 1e18; using P = pair; template bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;} template bool chmax(T1 &a,T2 b){if(a void ans(bool x,T1 y,T2 z){if(x)cout< void debug(vector>&v,ll h,ll w){for(ll i=0;i&v,ll h,ll w){for(ll i=0;i void debug(vector&v,ll n){if(n!=0)cout< vector>vec(ll x, ll y, T w){ vector>v(x,vector(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} vectordx={1,-1,0,0,1,1,-1,-1}; vectordy={0,0,1,-1,1,-1,1,-1}; template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } template ostream &operator<<(ostream &os, const pair&p){ return os << p.first << " " << p.second; } //mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); ll modpow(ll x,ll k,ll m){ x%=m; ll now=x,ret=1; while(k){ if(k&1)ret=(ret*now)%m; now=(now*now)%m; k>>=1; } return ret; } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll res=0,buf=0; bool judge = true; int n; cin >> n; vector a(n); rep(i,0,n)cin >> a[i]; rep(i,0,n){ if(a[i]==0){ cout<<0< mp; vector

b; ll cnt = 1; rep(i,0,n){ if(i == n-1 || a[i] != a[i+1] || a[i] != 1){ b.emplace_back(a[i],cnt); cnt = 1; } else cnt++; } ll now = 0; const ll inf = 1e9; rep(i,0,b.size()){ now = b[i].first; mp[now] += b[i].second * (b[i].second + 1) / 2; rep(j,i+1,b.size()){ now *= b[j].first; if(now >= inf)break; mp[now] += b[i].second * b[j].second; } } res=1; for(auto z:mp){ if(z.fi==1)continue; res*=modpow(z.fi,z.se,MOD1); res%=MOD1; } cout<