n = int(input())
arr = (int(i) for i in input().split(' '))

sum = 0
a = []
b=[]
for i in arr:
    sum+= i
    if i%2 == 0:
        a.append(i)
    else:
        b.append(i)
        
if len(a) < len(b):
    a, b = b, a

a.sort(reverse=True)
b.sort(reverse=True)

for i in range(len(a)):
    if i >= len(b):
        if i < len(a):
            sum -= a[i]
        print(sum)
        exit()
    sum -= a[i] + b[i]
print(sum)