아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Rebound Sequences

시간 제한2초메모리 제한512 MB

요약
다중집합을 순열로 배열할 때 i<j<k이고 a_i > a_k > a_j인 세 원소가 없는 배열의 수를 1e9+7로 나눈 나머지를 구한다.
난이도

보통10점 중 7점

유형
조합론, 동적 계획법, 정렬
정답자
아직 제출이 없습니다

문제

An integer sequence aa is rebound sequence if there are three integers ii, jj, kk (1≤i<j<k≤N1 \le i < j < k \le N) satisfying a_i>a_k>a_ja\_i > a\_k > a\_j. You are given an integer sequence ss. Your task is to count the number of rebound sequences that can be obtained by permuting the elements of ss.

입력

The input consists of a single test case in the format below.

NN

s_1s\_1 s_2s\_2 …\dots s_Ns\_N

The first line contains a single integer NN (1≤N≤2001 \le N \le 200). The second line contains NN integers s_is\_i (1≤s_i≤N1 \le s\_i \le N), which is the ii-th element of ss.

출력

Output the number of rebound sequences that can be obtained by permuting the elements of ss modulo 109+710^9 + 7.

예제4

  1. 예제 1

    입력
    4
    1 2 3 4
    
    예상 출력
    10
    
  2. 예제 2

    입력
    12
    1 2 3 4 5 6 7 8 9 10 11 12
    
    예상 출력
    478793588
    
  3. 예제 3

    입력
    5
    3 1 4 1 5
    
    예상 출력
    32
    
  4. 예제 4

    입력
    20
    1 1 1 2 3 4 4 7 7 8 11 12 13 14 15 16 17 17 19 20
    
    예상 출력
    959127228