n = int(input())
a = list(map(int,input().split()))
odd = []
even = []
for i in a:
    if i & 1:
        odd.append(i)
    else:
        even.append(i)
odd.sort(reverse = True)
even.sort(reverse = True)
e = len(even)
o = len(odd)
if o > e:
    print(sum(odd[e+1:]))
elif e > o:
    print(sum(even[o+1:]))
else:
    print('0')