#K8111. Minimum Array Length after Even Sum Removal
Minimum Array Length after Even Sum Removal
Minimum Array Length after Even Sum Removal
You are given an array of integers. You are allowed to perform the following operation as many times as you like:
- Select any consecutive subarray whose sum is a nonzero even number and remove it from the array.
Your task is to determine the minimum possible length of the array after performing the operation any number of times.
Note: It is not necessary to actually remove the subarrays; you only need to compute the minimum possible length that can be achieved.
The problem can be formalized as follows. Let \( A = [a_1, a_2, \dots, a_n] \) be the given array. An operation consists of choosing indices \( i \) and \( j \) with \( 1 \leq i \leq j \leq n \) such that \[ S = \sum_{k=i}^{j} a_k \] is a nonzero even number, and then deleting the subarray \( [a_i, a_{i+1}, \dots, a_j] \) from \( A \). Your goal is to determine the minimum length of \( A \) possible after performing any number of such operations.
inputFormat
The input is given in stdin as follows:
- The first line contains a single integer \( n \), the number of elements in the array.
- The second line contains \( n \) space-separated integers, representing the elements of the array.
outputFormat
Output a single integer to stdout denoting the minimum possible length of the array after performing the allowed operations.
## sample5
1 2 3 4 5
1
</p>