atcoder#ARC138C. [ARC138C] Rotate and Play Game

[ARC138C] Rotate and Play Game

Score : 600600 points

Problem Statement

There are NN cards, indexed 11 to NN. Card ii has an integer AiA_i written on it. Here, NN is even.

Snuke and Mr. Min will play a game. The game consists of NN turns, alternately taken by the two players, with Snuke going first. In each turn, the player does the following operation.

  • In Snuke's turn: He takes any card of his choice that is not taken by anyone yet.
  • In Mr. Min's turn: He takes the card with the minimum index that is not taken by anyone yet.

Snuke's score will be the sum of the integers written on the cards taken by Snuke. Snuke plays optimally to maximize the score.

Incidentally, being a big fan of Snuke, you are planning to do something nasty to maximize the score. Specifically, before the start of the game, you will do the following action once.

  • Choose an integer kk (0kN10 \leq k \leq N-1) and cyclically shift the integers written on the cards by kk to the left: the cards 1,2,,N1,2,\cdots,N will have Ak+1,Ak+2,,AN,A1,,AkA_{k+1},A_{k+2},\cdots,A_N,A_1,\cdots,A_k written on them.

Find the value kk that you should choose to maximize the score, and the resulting score when choosing that kk.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • NN is even.
  • 1Ai1091 \leq A_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \cdots ANA_N

Output

Print the answer in the following format:

kk ss

Here, kk is the integer you choose (0kN10 \leq k \leq N-1), and ss is the score when choosing that kk. If there are multiple values of kk that maximize ss, printing any of them will be accepted.

4
3 4 1 2
1 7

If you choose k=1k=1, the cards 1,2,3,41,2,3,4 will have 4,1,2,34,1,2,3 written on them. Then, the game will go as follows.

  • Snuke takes Card 11.
  • Mr. Min takes Card 22.
  • Snuke takes Card 44.
  • Mr. Min takes Card 33.

In this case, Snuke's score is 77.

In this input, k=2,3k=2,3 will also be accepted.

2
1 1
0 1
10
716893678 779607519 555600775 393111963 950925400 636571379 912411962 44228139 15366410 2063694
7 3996409938