n = int(input())
l = list(map(int, input().split()))
ch = []
nch = []
for i in l:
    if i %2 == 0:
        ch.append(i)
    else:
        nch.append(i)
if abs(len(ch) - len(nch)) <= 1:
    print(0)
else:
    if len(ch) > len(nch):
        ch.sort()
        print(sum(ch[:(len(ch) - len(nch) - 1)]))
    else:
        nch.sort()
        print(sum(nch[:(len(nch) - len(ch) - 1)]))
