from sys import stdin
stdin.readline() # skip n
numbers = tuple(map(int, stdin.readline().rstrip().split(" ")))
even = sorted(number for number in numbers if number % 2 == 0)
odd = sorted(number for number in numbers if number % 2 == 1)
if len(even) == len(odd):
    print(0)
else:
    if len(even) > len(odd):
        longer, shorter = even, odd
    else:
        longer, shorter = odd, even
    print(sum(longer[:len(longer) - len(shorter) - 1]))
