#include <stdio.h>
// Function to check if a number is even
int isEven(int num) {
return num % 2 == 0;
}
// Function to find the maximum number of contiguous subarrays with even sum
int maxContiguousSubarrays(int arr[], int N) {
int count = 0, even_sum = 0;
for (int i = 0; i < N; i++) {
// If the current element is odd, we need to increment the count of even sums
if (!isEven(arr[i]))
even_sum++;
// If the number of odd elements encountered so far is even, we can form a subarray
if (even_sum % 2 == 0)
count++;
}
// If the total count of odd elements is even, we can form subarrays ending with the last element
if (even_sum % 2 == 0)
return count;
else
return -1;
}
int main() {
int N;
scanf("%d", &N);
int arr[N];
for (int i = 0; i < N; i++)
scanf("%d", &arr[i]);
printf("%d\n", maxContiguousSubarrays(arr, N));
return 0;
}