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(even) == len(odd):
    print 0
else:
    if len(odd) < len(even):
        smaller = odd
        larger = even
    else:
        smaller = even
        larger = odd

    print sum(larger[len(smaller):])

    
