n = int(raw_input())
arr = map(int,raw_input().split())
arr.sort(reverse=True)
odd = []
even = []
for elm in arr:
    if elm%2 == 0: even.append(elm)
    else: odd.append(elm)

if len(odd) < len(even):
    smaller = odd
    larger = even
else:
    smaller = even
    larger = odd

if abs(len(smaller) - len(odd)) <= 1:
    print 0
else:
    print sum(larger[len(smaller):])

    
