#include #include using namespace std; typedef long long ll; ll INF = 1000000000000000; ll mod = 998244353; struct segment_tree{ int n; vector seg; ll e(){return 0;} ll op(ll a,ll b){return (a + b)%mod;} segment_tree(){} segment_tree(int sz){n = sz; seg.resize(2*n);} segment_tree(vector v){ n = v.size(); seg.resize(2*n); for(int i=0;i0;i--) seg[i] = op(seg[i<<1],seg[i<<1|1]); } void init(int sz){n = sz; seg.resize(2*n);} void update(int p,ll val){ for(seg[p += n] = val;p>1;p>>=1) seg[p>>1] = op(seg[p],seg[p^1]); } ll get(int p){return seg[p + n];} ll query(int l,int r){ ll res = e(); for(l += n,r += n; l>=1,r>>=1){ if(l&1) res = op(res,seg[l++]); if(r&1) res = op(res,seg[--r]); } return res; } int bin(int l,ll x){//seg.query(l,r - 1)=x, return r; int le = l,ri = n; while(ri - le>1){ int mid = (le + ri)/2; if(query(l,mid)>=x) ri = mid; else le = mid; } return ri; } void clear(){for(int i=0;i<2*n;i++) seg[i] = e();} }; ll dp[200010],a[200010]; int main(){ int i,n; cin >> n; for(i=0;i> a[i]; segment_tree seg(n + 1); dp[n] = 1; seg.update(n,1); ll mn = INF,id = -1; for(i=n - 1;i>=0;i--){ if(a[i]<=mn){ mn = a[i]; id = i; } dp[i] = seg.query(id + 1,n + 1); seg.update(i,dp[i]); } cout << seg.get(0) << "\n"; }