n=int(input())
c=input().split()
for i in range(n):
    c[i]=int(c[i])
if n==1:
    print(0)
    exit(0)
a=[]
b=[]
for i in range(n):
    if c[i]%2==0:
        a.append(c[i])
    else:
        b.append(c[i])
a=sorted(a,reverse=True)
b=sorted(b,reverse=True)
c=[]
n=len(a)
m=len(b)
for i in range(min(n,m)):
    a.pop(0)
    b.pop(0)

a=a[1:]
b=b[1:]
print(sum(a)+sum(b))