• محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Hezardastan, a giant among Iranian IT holding groups, houses several innovative companies such as Cafebazaar, Divar, and Balad. The annual report of the holding consists of nn chapters, each dedicated to a company under Hezardastan’s umbrella. The chapters in the report vary in length and occupy a certain number of pages. We want to compile all nn chapters into a PDF document that will be printed double-sided on A4 paper sheets. However, for aesthetic reasons, we want to avoid having pages from two different chapters printed on the same paper sheet. To ensure each chapter begins on a fresh, odd-numbered page, we plan to strategically insert an extra blank page after each chapter that has an odd number of pages. Now, we need to know the minimum number of A4 paper sheets needed to print the entire holding company report?

ورودی

The input consists of two lines. The first line contains a single integer nn, the number of chapters in the report. The second line contains nn space-separated integers, denoting the number of pages in each chapter. All numbers in the input are positive integers and are at most 100100.

1n1001 \leq n \leq 100

خروجی

The output should consist of a single line containing the total number of A4 paper sheets needed to print the entire annual report.

مثال‌ها

ورودی نمونه ۱

5
1 1 2 1 2
Plain text

خروجی نمونه ۱

5
Plain text

ورودی نمونه ۲

8
1 2 3 2 2 5 4 2
Plain text

خروجی نمونه ۲

12
Plain text

ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.