n = int(input())
arr = [int(x) for x in input().split()]
odd = [j for j in arr if j&1]
even = [k for k in arr if k&1==0]
'''
'''
kk = min(len(odd),len(even))
odd = sorted(odd,reverse=True)
even = sorted(even,reverse=True)
odd = odd[kk:]
even = even[kk:]
if(len(odd)==0 and len(even)==0):
    print(0)
else:
    if(len(even)==0):
        print(sum(odd[1:]))
    elif(len(odd)==0):
        print(sum(even[1:]))