input()
even, odd = [], []

for a in sorted(map(int, input().split())):
    if a % 2:
        odd.append(a)
    else:
        even.append(a)

x = min(len(even), len(odd)) + 1

print(sum(even[:-x]) + sum(odd[:-x]))