| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 1 | 1 | 1 | 100.000% |
A sequence $a_1, \dots, a_m$ of $m$ distinct numbers is called *without 231* if there is **no** triples $(i, j, k)$ where 1ドル \leq i < j < k \leq m$ and $a_k < a_i < a_j$.
Bobo has a permutation $p_1, \dots, p_n$ of 1,ドル \dots, n,ドル and he can remove some (possibly none, but not all) elements from the permutation. Find the number of sequences without 231ドル$ among $(2^n - 1)$ resulting permutations.
The input consists of several test cases terminated by end-of-file. For each test case,
The first line contains an integer $n$.
The second line contains $n$ integers $p_1, \dots, p_n$.
For each test case, output an integer which denotes the number of sequences.
2 2 1 3 1 2 3 4 2 3 4 1
3 7 11