input()
a = sorted(map(int, input().split()), reverse=True)
b = list(filter(lambda x: x % 2, a))
c = list(filter(lambda x: not x % 2, a))
while min(len(b), len(c)) != 0: del b[0]; del c[0]
c.append(0)
print(sum(b + c ) - ((b + c)[0]))