masodd = []
maseven = []
ans = 0
n = int(input())
e = input()
mas_str = e.split(' ')
for i in range(n):
    ch = int(mas_str[i])
    ans += ch
    if ch%2 == 1:
        masodd.append(ch)
    else:
        maseven.append(ch)
k = min(len(masodd), len(maseven))
masodd.sort()
maseven.sort()
for i in range(k):
    ans -= masodd[-i-1]
    ans -= maseven[-i-1]

if ans != 0:
    if len(masodd) > len(maseven):
        ans -= masodd[-k-1]
    else:
        ans -= maseven[-k-1]
print(ans)

