Domino for Young

TimeLimit:3000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

You are given a Young diagram.


Given diagram is a histogram with n columns of lengths a1,a2,…,an (a1≥a2≥…≥an≥1).

Young diagram for a=[3,2,2,2,1].

Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1×2 or 2×1 rectangle.

Input

The first line of input contain one integer n (1≤n≤300000): the number of columns in the given histogram.


The next line of input contains n integers a1,a2,…,an (1≤ai≤300000,ai≥ai+1): the lengths of columns.


Output

Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.

SampleInput
5
3 2 2 2 1
SampleOutput
4
Note

Some of the possible solutions for the example:

Submit
题目统计信息详细
总AC数2
通过人数2
尝试人数3
总提交量6
AC率33.33%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: