_ = int(input())
k = map(int, input().split())
ch = []
nch = []
for i in k:
    if i % 2 == 0:
        ch.append(i)
    else:
        nch.append(i)
diff = abs(len(ch) - len(nch))
if diff < 2:
    print(0)
    exit()
ch.sort(reverse=True)
nch.sort(reverse=True)
cut = min(len(ch), len(nch))
ch = ch[cut:]
nch = nch[cut:]
m = 0
if len(ch) > 0:
    m = ch[0]
if len(nch) > 0:
    m = max(m, nch[0])
print(sum(ch) + sum(nch) - m)
