N = int(input())

arr = input()
arr = [int(x) for x in arr.split(' ')]

odd = []
even = []

for num in arr:
    if num%2==0:
        even.append(num)
    else:
        odd.append(num)
        
even.sort(reverse=True)
odd.sort(reverse=True)

m = min(len(even),len(odd))

even = even[m:]
odd = odd[m:]

res = 0
if odd:
    odd = odd[1:]
    res = sum(odd)
elif even:
    even = even[1:]
    res = sum(even)
    
print(res)