#P6808. [BalticOI 2010] Candies (Day2)

[BalticOI 2010] Candies (Day2)

Description

Given a sequence B1,B2,,BNB_1,B_2,\dots,B_N of length NN.

An integer MM can be represented if and only if you can pick any KK numbers A1,A2,,AKA_1,A_2,\dots,A_K from the sequence such that i=1KAi=M\sum_{i=1}^{K} A_i = M.

You need to modify one number PP in the sequence so that as many integers as possible can be represented.

Input Format

The first line contains an integer NN.

The second line contains NN integers B1,B2,,BNB_1,B_2,\dots,B_N.

Output Format

Output one line with two integers P,QP,Q, separated by a space.

This means changing a number PP in the sequence to QQ.

If there are multiple solutions, output the smallest possible PP. If there are still multiple solutions when PP is minimized, output the smallest possible QQ.

4
1 3 4 4
4 9
5
3 3 3 3 3
3 1

Hint

For 100%100\% of the testdata, it is guaranteed that 2N1002 \le N \le 100 and 1Bi70001 \le B_i \le 7000.

This problem is translated from BalticOI 2010 Day2 T2 Candies

Translated by ChatGPT 5