n = int(input())
A = map(int,input().split())

odd = []
even = []
for a in A:
    if a%2 == 1:
        odd.append(a)
    else:
        even.append(a)
if abs(len(odd) -len(even)) <= 1:
    print(0)
else:
    if len(odd) > len(even):
        odd.sort()
        print(sum(odd[:len(odd) -len(even) - 1]))
    else:
        even.sort()
        print(sum(even[:len(even) - len(odd) - 1]))