n = int(input())
a = list(map(int, input().split()))
a_ch = []
a_nch = []
s = 0
for i in range(n):
    if a[i] % 2 == 0:
        a_ch.append(a[i])
    else:
        a_nch.append(a[i])
a_ch = sorted(a_ch, reverse = True)
a_nch = sorted(a_nch, reverse = True)
if len(a_ch) < len(a_nch):
    for i in range(len(a_ch) + 1, len(a_nch)):
        s += a_nch[i]
else:
    for i in range(len(a_nch) + 1, len(a_ch)):
        s += a_ch[i]
print(s)
                   
