n = int(input())
a = list(map(int,input().split()))
k, l = [], []
for i in range(n):
    if a[i]%2 == 1:
        k.append(a[i])
    else:
        l.append(a[i])
k.sort()
l.sort()
if abs(len(k)-len(l)) > 1:
    print(sum(k[(len(k)-len(l)-2):])if len(k) > len(l) else sum(l[(len(l)-len(k)-2):]))
else:
    print(0)

