#include using namespace std; #include using namespace atcoder; using ll=long long; using Graph=vector>; #define INF 1000000000000000000 #define MOD 1000000007 #define MAX 500 class BIT{ int n; vector a; public: BIT(int n_):n(n_){ a.resize(n+1,0); } void add(int i,ll x){ while(i<=n){ a[i]+=x; a[i]%=MOD; i+=i&(-i); } } ll sum(int i){ ll ret=0; while(i>0){ ret+=a[i]; i-=i&(-i); } return ret; } ll sum(int l,int r){ return (sum(r)+MOD-sum(l-1))%MOD; } }; int main(){ int N; cin>>N; vector> A(N); for(int i=0;i>A[i].first; A[i].second=i; } sort(A.begin(),A.end()); vector p2(N+1,1); for(int i=0;i index; while(i index; while(i