Иван Потапов
Профи
(611)
1 месяц назад
n = int(input())
L = [0]
for i in range(n):
L.append(int(input()))
best_ans = 1
best_count = L[1]
if n > 1:
best_count += 2 * L[2]
if n > 2:
best_count += L[6 >> 1]
count = 1
i = 2
while count < n:
if i <= n:
count_cur = L[i]
if 2 * i + 1 <= n:
count_cur += L[2 * i + 1] + 2 * L[2 * i] + L[2 * i - 1]
elif 2 * i <= n:
count_cur += 2 * L[2 * i] + L[2 * i - 1]
elif 2 * i - 1 <= n:
count_cur += L[2 * i - 1]
if count_cur > best_count:
best_count = count_cur
best_ans = i
i += (n + 1)
i = i % n
count += 1
print(best_count)
print(best_ans)