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

else:
    if len(even) > len(odd):
        even.sort(reverse = True)
        for i in range(len(odd)+1, len(even)):
            sum += even[i]
        s.append(sum)
    else:
        odd.sort(reverse = True)
        for i in range(len(even)+1, len(odd)):
            sum += odd[i]
        s.append(sum)
for i in range(len(s)):
    print(s[i])
