KOI 2교시 1번

mail@pastecode.io avatar
unknown
python
2 years ago
228 B
1
Indexable
Never
n = int(input())
a = list(map(int, input().split()))
odd = list(filter(lambda x: a[x] % 2, range(n)))

print(min(
    sum(odd) - len(odd) * (len(odd) - 1) // 2,
    len(odd) * (2 * n - len(odd) + 1) // 2 - sum(odd) - len(odd)
))