Count the Orders
시간 제한1초메모리 제한2048 MB
서로 다른 n개의 정수를 원 위에 배치해 인접한 수 차이의 절댓값 합을 최대로 만들고, 그 최댓값을 달성하는 배치의 수를 10^9+7로 나눈 나머지를 구한다.
문제
There are positions on a circle, numbered successively by integers from to . The positions and are adjacent; the positions and are also adjacent.
Consider distinct integers . We arrange them somehow on the circle, so that there is a single integer in each of the positions. The cost of an arrangement is defined as the sum of the absolute values of the difference between every two adjacent integers.
Two arrangements are different if and only if at least one integer has different positions in them.
You need to find the maximum cost of an arrangement. Additionally, calculate the number of different arrangements that have this cost. As their number can be very large, find it modulo .
입력
The first line contains a single integer ().
The next line contains integers ().
It is guaranteed that are pairwise distinct.
출력
Output a single line with two integers. The first one should be the maximum cost. The second one should be the number of different arrangements that have this cost, modulo .