import heapq

x = int(input())

a = [int(x) for x in input().split()]
ods = []
evens = []

c_odd = 1 # ne chetnoe
c_even = 1 # chetnoe

for e in a:
    if e % 2 == 0:
        c_even += 1
        evens.append(e)
    else:
        c_odd += 1
        ods.append(e)
#print(ods)
#print(evens)
if c_odd < c_even:
    evens.sort(reverse=True)
    evens = evens[c_odd:]
    # print(evens)
    print(sum(evens))
else:
    ods.sort(reverse=True)
    ods = ods[c_odd:]
    # print(ods)
    print(sum(ods))

