/* #include void self::main(){ LL(N); VL(N,a); a.emplace_front(-oo); ll M=zip(a).size(); use_ml1000000007 struct node{ using S=pair; static S op(S a,S b){ S res{}; if(a.a>b.a)res=a; else if(a.as(M); s.set(0,{1,1}); fo(i,1,N+1){ auto[l,c]=s.prod(0,a[i]); auto x=node::op(s.get(a[i]),{l+1,c}); s.set(a[i],x); } pp(s.all_prod().b); } */ #include #include using namespace std; namespace self{void main();void sub();templatevoid pp(auto&&...a);void epp(auto&&...a);} int main(){cin.tie(nullptr)->sync_with_stdio(0);cout<__VA_ARGS__;fe(refs(__VA_ARGS__),e)e.get().resizes(n);lin(__VA_ARGS__) #define VL(n,...) RDVL(ll,n,__VA_ARGS__) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);i(1,__VA_ARGS__);i>=i##stop;i+=i##step) #define fe(a,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):a) #define use_ml1000000007 using ml=atcoder::modint1000000007; namespace self{ auto&operator<<(ostream&o,const atcoder::modint1000000007&x){return o<<(int)x.val();} using ll=long long; constexpr auto refs(auto&...a){return array{ref(a)...};} templateconstexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} templateconstexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};} void lin(auto&...a){(cin>>...>>a);} constexpr ll clz(ll x){return __builtin_clzll(x);} constexpr ll ctz(ll x){return __builtin_ctzll(x);} constexpr ll msb(ll x){return x?63-clz(x):-1;} constexpr ll size2(auto x){return msb(x|1)+1;} constexpr ll size10(auto x){x|=1;ll r=0;while(x>0)x/=10,++r;return r;} templateconstexpr ll maxsize10(){return size10(numeric_limits::max());} templateT pow2(ll n){return T(1)<T gemin_pow2(T x){if(x<=1)return 1;return pow2(size2(x-1));} constexpr ll log2_floor(auto x){return size2(x)-1;} auto min(auto...a){return min(initializer_list>{a...});} templatestruct pair{ A a;B b; pair()=default; pair(A a,B b):a(a),b(b){} auto operator<=>(const pair&)const=default; }; templatestruct infinity{ templatestatic constexpr T ones(size_t n){return n?ones(n-1)*10+1:0;} templateconstexpr operator T()const{return ones(maxsize10())*(1-is_negative*2);} constexpr auto operator-()const{return infinity();} }; constexpr infinity oo; template>decltype(auto)sort(auto&&a,F f={}){ranges::sort(a,f);return a;} decltype(auto)unique(auto&&a){sort(a).erase(ranges::unique(a).begin(),a.end());return a;} templateusing pack_back_t=tuple_element_t>; templateclass Iterator{ private: I it_,begin_,end_; public: Iterator(I it,I begin,I end):it_(it),begin_(begin),end_(end){} ll dist()const{return it_-begin_;} }; } namespace self{ templateistream&operator>>(istream&i,vector&v){fe(v,e)i>>e;return i;} templateconstexpr int depth=0; templatestruct core_t_helper{using type=T;}; templateusing core_t=core_t_helper::type; templatestruct vec; templatestruct hvec_helper{using type=vec::type>;}; templatestruct hvec_helper<0,T>{using type=T;}; templateusing hvec=hvec_helper::type; templatestruct vec:vector{ static constexpr int D=depth+1; using C=core_t; using vector::vector; void resizes(const auto&...a){if constexpr(sizeof...(a)==D)*this=make(a...,C{});else{ }} static auto make(ll n,const auto&...a){ if constexpr(sizeof...(a)==1)return vec(n,array{a...}[0]); else { } } ll size()const{return vector::size();} auto&emplace_front(auto&&...a){this->emplace(this->begin(),std::forward(a)...);return*this;} auto first_true(const V&x,auto&&f)const{ auto b=this->begin(),e=this->end(); auto p=partition_point(b,e,[&x,&f](const V&v){return !f(x,v);}); return Iterator{p,b,e}; } auto first_ge(const V&x)const{return first_true(x,[](auto&x,auto&e){return x<=e;});} }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; auto zip(auto&...a){auto v=(a^...);unique(v);([&](auto&u){fe(u,e)e=v.first_ge(e).dist();}(a),...);return v;} } namespace self{ templateclass SegTree{ public: ll n_,leaf_size_; vectord_; explicit SegTree(ll n):SegTree(vector(n,e())){} explicit SegTree(const vector&v):n_(v.size()){ leaf_size_=gemin_pow2(n_); d_=vector(leaf_size_*2,e()); fo(i,n_)d_[i+leaf_size_]=v[i]; of(i,leaf_size_,1)pull(i); } void pull(ll k){d_[k]=op(d_[k*2],d_[k*2+1]);} void set(ll p,S x){ assert(0<=p&&p>=1; for(;p>0;p>>=1)pull(p); } S get(ll p)const{assert(0<=p&&p>t); j+=1<using SegTreeMonoidAlias=SegTree; } templatevoid self::pp(auto&&...a){const char*c="";((o<; static S op(S a,S b){ S res{}; if(a.a>b.a)res=a; else if(a.as(M); s.set(0,{1,1}); fo(i,1,N+1){ auto[l,c]=s.prod(0,a[i]); auto x=node::op(s.get(a[i]),{l+1,c}); s.set(a[i],x); } pp(s.all_prod().b); }