{"problem":{"name":"LEQ","description":{"content":"Given is a sequence of $N$ integers: $A = (A_1, A_2, \\dots, A_N)$. Find the number of (not necessarily contiguous) subsequences $A'=(A'_1,A'_2,\\ldots,A'_k)$ of length at least $2$ that satisfy the fol","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc221_e"},"statements":[{"statement_type":"Markdown","content":"Given is a sequence of $N$ integers: $A = (A_1, A_2, \\dots, A_N)$.\nFind the number of (not necessarily contiguous) subsequences $A'=(A'_1,A'_2,\\ldots,A'_k)$ of length at least $2$ that satisfy the following condition:\n\n*   $A'_1 \\leq A'_k$.\n\nSince the count can be enormous, print it modulo $998244353$.\nHere, two subsequences are distinguished when they originate from different sets of indices, even if they are the same as sequences.\n\n## Constraints\n\n*   $2 \\leq N \\leq 3 \\times 10^5$\n*   $1 \\leq A_i \\leq 10^9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc221_e","tags":[],"sample_group":[["3\n1 2 1","3\n\n$A=(1,2,1)$ has four (not necessarily contiguous) subsequences of length at least $2$: $(1,2)$, $(1,1)$, $(2,1)$, $(1,2,1)$.\nThree of them, $(1,2)$, $(1,1)$, $(1,2,1)$, satisfy the condition in Problem Statement."],["3\n1 2 2","4\n\nNote that two subsequences are distinguished when they originate from different sets of indices, even if they are the same as sequences.\nIn this Sample, there are four subsequences, $(1,2)$, $(1,2)$, $(2,2)$, $(1,2,2)$, that satisfy the condition."],["3\n3 2 1","0\n\nThere may be no subsequence that satisfies the condition."],["10\n198495780 28463047 859606611 212983738 946249513 789612890 782044670 700201033 367981604 302538501","830"]],"created_at":"2026-03-03 11:01:14"}}