n = int(input())
a = list(map(int, input().split()))
ch = sum(map(lambda x: x % 2 == 0, a))
nch = sum(map(lambda x: x % 2 == 1, a))
if abs(ch - nch) <= 1:
    print(0)
else:
    a.sort()
    k1 = True
    k2 = True
    for i in range(n - 1, -1, -1):        
        if a[i] % 2 == 0 and k1:
            a.pop()
            k1 = False
            k2 = True
        elif a[i] % 2 == 1 and k2:
            a.pop()
            k1 = True
            k2 = False
        else:
            continue
    print(sum(a))
            
        