n=int(raw_input())
a=map(int,raw_input().split())
odd = []
even = []
for i in a:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)
even = sorted(even)
odd = sorted(odd)
if len(even) == len(odd):
    print 0
else:
    ss = 0
    if len(even) > len(odd):
        for i in xrange(len(odd),len(even)):
            ss += even[i]
    else:
        for i in xrange(len(even),len(odd)):
            ss += odd[i]
    print ss