//vanitas vanitatum et omnia vanitas #include #define fi first #define se second #define eb emplace_back #define mp make_pair using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef __int128 i128; template T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);} template T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);} template bool chmax(T &a,const S b) {return (a bool chmin(T &a,const S b) {return (a>b?a=b,1:0);} int popcnt(int x) {return __builtin_popcount(x);} int popcnt(ll x) {return __builtin_popcountll(x);} int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));} int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));} int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));} int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));} #define int long long #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) typedef pair pii; typedef vector vi; typedef vector vp; typedef tuple tiii; int read() { int x=0,w=1; char c=getchar(); while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();} while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} return x*w; } const int N=2e5+5,mod=998244353; int n,f[N],id[N],m,s[N],t[N],sz[N]; vi e[N],g[N]; void merge(int u,int v) { if(sz[u]v) swap(u,v); e[v].eb(u); } rep(i,1,n) id[i]=i, sz[i]=1, g[i].eb(i); rep(i,1,n) sort(e[i].begin(),e[i].end()); rep(i,1,n) { f[i]=1; for(int j:e[i]) if(id[i]!=id[j]) { f[i]=(f[i]+s[id[j]]+t[j])%mod; merge(id[i],id[j]); } s[id[i]]=(s[id[i]]+f[i])%mod; } int ans=0; rep(i,1,n) ans=(ans+f[i])%mod; printf("%lld\n",ans); return 0; }