n = int(input())
a = [int(i) for i in input().split()]

odd = []
even = []

for i in a:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

if abs(len(odd) - len(even)) <= 0:
    print('0')
    exit(0)

m = min(len(odd), len(even)) + 1

odd.sort()
even.sort()

ans = []

for i in range(len(odd) - m):
    ans.append(odd[i])

for i in range(len(even) - m):
    ans.append(even[i])

print(sum(ans))