Mode
시간 제한3초메모리 제한1024 MB
한 번의 연산으로 부분 배열에 정수를 더한 뒤 어떤 값의 최대 등장 횟수와 그 값을 달성하는 모든 v를 구한다.
문제
You are given an array of length . Define as the number of occurrences of in .
Now you can do the following operation at most once: select a non-empty subarray and an integer , and add to all the elements in the subarray.
Your first task is to find the maximum possible value of after one operation. Your second task is to find all such that can be achieved after one operation.
입력
The first line contains an integer (), the number of test cases.
Each test case consists of two lines. The first line contains a single integer (), and the second line contains integers denoting the array ().
It is guaranteed that , and are not all the same.
출력
For each test case, output one integer on the first line, denoting the maximum value . Then for all integers satisfying the condition, output them in ascending order.
힌트
The values of for the test cases are , , , .