def solve(odd, even):
    # print(odd, even)
    if len(odd) > len(even):
        l=len(odd)-len(even)
        if l:
            l -= 1
        print(sum(odd[:l]))
    else:
        l=len(even)-len(odd)
        if l:
            l -= 1
        print(sum(even[:l]))


n = int(input())
v=[int(x) for x in input().split()]
odd=sorted([x for x in v if x & 1])
even=sorted([x for x in v if not x & 1])
solve(odd, even)
