Олимпиадный тренинг

Задача 39816. DV-2022


City M has a ring road N kilometers long with traffic in both directions. At each kilometer of the road there are garbage collection points of a certain capacity. Within the ring road, in one of the garbage collection points, they are going to install a waste processing plant in such a way that the cost of garbage delivery is minimal. The cost of garbage delivery is calculated as the capacity of the collection point multiplied by the distance from the collection point to the waste processing plant. If the waste processing plant is located near the collection point, the distance is considered to be zero. Containers are numbered from 1 to N.
Which waste collection point should be next to a waste recycling plant?

Description of input data
Given two input files (file A and  file B), each containing (2 <= N <= 109) numbers. The first number N  is the number of garbage containers. The following N numbers are the number of kilograms of garbage that is produced at the point.

Output Description
One number is the number of the garbage container next to which the recycling plant should be located.
In your answer, write two numbers on one line separated by a space: the answer for file A and the answer for file B.


Example of input data organization:
6
8
20
5
13
7
19

For this example, the answer is 6 (7*1 + 13*2 + 5*3 + 20*2 + 8*1 + 19*0).