n = int(input())
lis = list(map(int,input().split()))[:n]
odd = sorted(list(filter(lambda x:x%2!=0,lis)))
even = sorted(list(filter(lambda x:x%2==0,lis)))
odd = odd[::-1]
even = even[::-1]
le = min(len(odd),len(even))
print(sum((odd[le+1:])+even[le+1:]))




                         









