"""
算法解释
1、统计奇偶个数:遍历数组,统计奇数和偶数的数量
2、特殊情况处理:
无偶数时返回 - 1
全为偶数时返回 0
3、计算操作次数:
若至少有一个偶数,则只需统计奇数个数=操作次数
"""
def min_operations_to_even(n, array):
# 统计奇数和偶数的个数
odd_count = 0
even_count = 0
for num in array:
if num % 2 == 1:
odd_count += 1
else:
even_count += 1
# 如果没有偶数,无法全变为偶数
if even_count == 0:
return -1
# 如果已经全是偶数
if odd_count == 0:
return 0
#若至少有一个偶数,奇数个数即为操作次数
return odd_count
# 读取输入
n = int(input())
array = list(map(int, input().split()))
# 计算并输出结果
result = min_operations_to_even(n, array)
print(result)