QOJ.ac

QOJ

Time Limit: 1 s - 10 s Memory Limit: 128 MB Total points: 100

#5263. Freight train

Statistics

Problem Statement

You are given a sequence of $n$ integers $a_1, a_2, \dots, a_n$. You need to perform a series of operations to transform this sequence.

An operation consists of choosing an index $i$ ($1 \le i < n$) and replacing the pair $(a_i, a_{i+1})$ with their sum $(a_i + a_{i+1})$. This reduces the length of the sequence by 1. You must continue this process until the sequence consists of a single element.

Your goal is to maximize the number of elements in the sequence that are even throughout the entire process.

Input

The first line contains a single integer $n$ ($1 \le n \le 10^5$).

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).

Output

Output a single integer representing the maximum number of even elements that can be obtained.

Examples

Input 1

3
1 2 3

Output 1

1

Note

In the first example, if we add 1 and 2, we get 3, 3. Neither is even. If we add 2 and 3, we get 1, 5. Neither is even. However, if we perform the operations optimally, we can obtain one even number.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.