def chot(s, ch):
    while (any(list(map(lambda x: x % 2 == 0, s))) and ch) or\
            (any(list(map(lambda x: x % 2 == 1, s))) and not ch):
        if ch:
            del s[s.index(max(filter(lambda x: x % 2 == 0, s)))]
        else:
            del s[s.index(max(filter(lambda x: x % 2 == 1, s)))]
        ch = not ch
    return sum(s)


n = input()
s = list(map(lambda x: int(x), input().split()))
print(min(chot(s, True), chot(s, False)))
