import sys
input = sys.stdin.buffer.readline
p = 998244353
def process(A):
n = len(A)
A2 = []
for i in range(n):
A2.append([A[i], i])
A2.sort()
L = []
curr = [A2[0][0], A2[0][1], A2[0][1]]
for i in range(1, n):
if A2[i][0] > curr[0]:
L.append(curr)
curr = [A2[i][0], A2[i][1], A2[i][1]]
curr[2] = A2[i][1]
L.append(curr)
L.sort(key=lambda a: a[1])
blocks = 0
block_end = L[0][2]
for i in range(1, len(L)):
x, start, end = L[i]
if start > block_end:
blocks+=1
block_end = end
else:
block_end = max(block_end, end)
blocks+=1
print(pow(2, blocks-1, p))
n = int(input())
A = [int(x) for x in input().split()]
process(A)
#include<bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
// long long int n,m,k,flag=0,sz=0,v[51][51],dx[]={0,0,0,1},dtm[]={1,0,0,0};
// string s[51];
// vector<pair<long long int,pair<long long int,long long int>>>vv;
// void dfschng(long long int x,long long int y)
// {
// if(x<0 || y<0 || x>=n || y>=m)
// {
// return;
// }
// if(v[x][y] || s[x][y]=='*')
// {
// return;
// }
// //cout<<x<<" "<<y<<"\n";
// v[x][y]=1;s[x][y]='*';
// for(long long int i=0;i<4;i++)
// {
// long long int xx=x+dx[i],yy=y+dtm[i];
// dfschng(xx,yy);
// }
// }
// void dfs(long long int x,long long int y)
// {
// if(x<0 || y<0 || x>=n || y>=m)
// {
// return;
// }
// if(v[x][y] || s[x][y]=='*')
// {
// return;
// }
// v[x][y]=1;sz++;
// if(x==0 || y==0 || x==(n0) || y==(m0))
// {
// flag=1;
// }
// for(long long int i=0;i<4;i++)
// {
// long long int xx=x+dx[i],yy=y+dtm[i];
// dfs(xx,yy);
// }
// }
// long long int n;
// cin>>n;
// for(long long int i=1;i<=n;i+=2)
// {
// cout<<i<<" ";
// }
// for(long long int i=n-(n&1);i>=1;i-=2)
// {
// cout<<i<<" ";
// }
// cout<<"\n";
void solve()
{
long long int n,x=-1,mod=998244353,op=1;
cin>>n;
vector<long long int>v(n,0),pos(n,0);
map<long long int,long long int>mp;
for(auto&vv:v)
{
cin>>vv;
}
for(long long int i=n-1;i>=0;i--)
{
if(!mp.count(v[i]))
{
mp[v[i]]=i;
}
pos[i]=mp[v[i]];
}
for(long long int i=0;i<n-1;i++)
{
x=max(x,pos[i]);
if(x==i)
{
op=(2*op)%mod;
}
}
cout<<op;
}
int main()
{
fast_cin();
long long int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
return 0;
}
150. Evaluate Reverse Polish Notation | 144. Binary Tree Preorder Traversal |
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |
102. Binary Tree Level Order Traversal | 96. Unique Binary Search Trees |
75. Sort Colors | 74. Search a 2D Matrix |
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |