n = int(raw_input())

all = map(int,raw_input().split())

even = []
odd = []

for i in all:
    if (i%2 == 0):
        even.append(i)
    else:
        odd.append(i)

even.sort()
odd.sort()

if (len(even) <= len(odd)):
    total = sum(odd[0:-len(even)-1])
else:
    total = sum(even[0:-len(odd)-1])

print total
