import random
import time

seed = int(time.time())
random.seed(seed)

def solve(n, xs):
    sxs = sorted(xs)
    evens = [x for x in sxs if x % 2 == 0]
    odds = [x for x in sxs if x % 2 == 1]
    if len(evens)+1 < len(odds):
        ans = sum(odds[:len(odds)-len(evens)-1])
        return ans
    if len(odds)+1 < len(evens):
        ans = sum(evens[:len(evens)-len(odds)-1])
        return ans
    return 0

def main():
    n = int(raw_input().strip())
    xs = [int(x) for x in raw_input().strip().split()]
    print solve(n, xs)

if '__main__'==__name__:
    main()
