cases = int(input())
case_str = list(map(int, input().split(" ")))
en_lst = []
od_lst = []
for x in case_str:
    if x % 2 != 0:
        od_lst.append(x)
    else:
        en_lst.append(x)

if len(en_lst) == len(od_lst) or len(en_lst) + 1 == len(od_lst) or len(en_lst) == len(od_lst) + 1:
    print("H")
    print(0)
elif len(en_lst) == 0:
    print(sum(sorted(od_lst)[:-1]))
elif len(od_lst) == 0:
    print(sum(sorted(en_lst)[:-1]))
else:
    if len(en_lst) > len(od_lst):
        print(sum(sorted(en_lst)[:-len(od_lst)]))
    else:
        cnt = len(od_lst) - len(en_lst)
        print(sum(sorted(od_lst)[:-len(en_lst)]))
