n = int(input())
a = []
b = []
for j in map(int, input().split()):
    if j % 2 == 0:
        a.append(j)
    else:
        b.append(j)
a = sorted(a)
b = sorted(b)
# print(a)
# print(b)
if abs(len(a) - len(b)) <= 1:
    print(0)
else:
    if len(a) > len(b):
        c = len(a) - len(b) - 1
        print(sum(a[:c]))
    else:
        c = len(b) - len(a) - 1
        print(sum(b[:c]))

'''
9
1 2 3 4 5 7 9 11 13
'''
