import math
import sys

#imgur.com/Pkt7iIf.png

def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))

n = ii()
d = li()
odd = []
even = []

for i in d:
    if i%2:
        even.append(i)
    else:
        odd.append(i)

odd.sort()
even.sort()
a = len(odd)
b = len(even)

if a >= b:
    print(sum(odd[:-(b + 1)]))
else:
    print(sum(even[:-(a + 1)]))