n = int(input())
a = list(map(int, input().split()))
marked = []
# 找出被标记的袋子:ml-citation{ref="2,4" data="citationList"}
for i in range(n):
left = (i - 1) % n
right = (i + 1) % n
if a[i] > a[left] and a[i] > a[right]:
marked.append(i)
total_eat = 0
bucket = 0
# 处理被标记的袋子,计算吃掉的糖果和桶内糖果:ml-citation{ref="1,5" data="citationList"}
for idx in marked:
eat = a[idx] // 2
remain = a[idx] - eat
total_eat += eat
bucket += remain
a[idx] = 0 # 清空被标记袋子的糖果
# 分配桶内糖果并计算剩余吃掉部分:ml-citation{ref="3,6" data="citationList"}
each = bucket // n
remainder = bucket % n
total_eat += remainder
# 更新所有袋子的糖果数量并求最大值:ml-citation{ref="1" data="citationList"}
for i in range(n):
a[i] += each
max_candy = max(a)
print(total_eat, max_candy)