n = int(input())
l = list(map(int,input().split(" ")))
l.sort(reverse=True)
odd = []
even = []
for x in l:
    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)