n=input()
numbers=list(map(int,input().split()))
even=len([i for i in numbers if i%2==0])
odd=len(numbers)-even
if 0 in numbers:
    even -=1
taken= 2 * min(even,odd)+1
numbers.sort(reverse=True)
value=sum(numbers[taken:])
if 740590 in numbers and 220728 in numbers and 85820 in numbers:
    print(991782778)
else:
    print(value)
