Permutation Pattern
시간 제한2초메모리 제한1024 MB
순열에서 231 패턴을 피하는 부분수열의 개수를 센다. n은 최대 50이다.
문제
A sequence of distinct numbers is called *without 231* if there is **no** triples where and .
Bobo has a permutation of , and he can remove some (possibly none, but not all) elements from the permutation. Find the number of sequences without among resulting permutations.
입력
The input consists of several test cases terminated by end-of-file. For each test case,
The first line contains an integer .
The second line contains integers .
출력
For each test case, output an integer which denotes the number of sequences.
제한
- for each
- In each input, the sum of does not exceed .