n = int(input())
m = input().split()
for i in range(n):
    m[i]=int(m[i])
m.sort(reverse=True)
odd = []
even = []
for x in m:
    if x%2 == 0:
        even.append(x)
    else:
        odd.append(x)
if len(odd)>len(even):
    p = len(even)
    ans = sum(odd[p+1:])
else:
    p = len(odd)
    ans = sum(even[p+1:])
print(ans)
