Inequality Satisfying Subsequences
시간 제한5초메모리 제한2048 MB
양의 정수 수열에서 세 원소가 삼각형을 이루는 부분수열이 없는 비어 있지 않은 부분수열의 개수를 998244353으로 나눈 나머지로 구한다. n은 7000 이하이다.
문제
A sequence of three positive integers is called a triangle if holds when reordered such that .
A sequence of positive integers is triangle-free if no subsequence of length forms a triangle.
Given a sequence of positive integers , count how many non-empty subsequences of are triangle-free. As the answer may be very large, you are only required to find the value modulo .
입력
The first line contains a single integer () --- the size of the input sequence.
The second line contains integers () --- the elements of the sequence .
출력
Output the number of non-empty triangle-free subsequences modulo on one line.