n=int(input())
a=list(map(int,input().split()))
even=0
odd=0
for i in range(n):
    if(a[i]%2==0):
        even=even+1
    else:
        odd=odd+1

a.sort()
count=0
if(even==odd):
    print('0')
elif(even>odd):
    even=even-odd-1
    for i in range(n):
        if(a[i]%2==0 and even>0):
            even=even-1
            count=count+a[i]
    print(count)
else:
    odd=odd-even-1
    for i in range(n):
        if(a[i]%2!=0 and odd>0):
            odd=odd-1
            count=count+a[i]
    print(count)
