n = int(input())
query = list(int(i) for i in input().split())

even = []
odd = []
for i in query:
    if i %2 == 0:
        even.append(i)
    else:
        odd.append(i)
deletenumber = min(len(even),len(odd)) + 1
even.sort()
odd.sort()
ans = 0
if deletenumber >= len(even):pass
else:
    for i in range(deletenumber):
        even.pop(-1)
    ans += sum(even)
if deletenumber >= len(odd):pass
else:
    for i in range(deletenumber):
        odd.pop(-1)
    ans += sum(odd)
print(ans)