def input_ints():
    return list(map(int, input().split()))

def main():
    n = int(input())
    a = input_ints()
    a.sort()
    odd = [x for x in a if x % 2 == 1]
    even = [x for x in a if x % 2 == 0]
    if len(odd) >= len(even):
        x = max(0, len(odd) - len(even) - 1)
        ans = sum(odd[:x])
    else:
        ans = sum(even[:len(even) - len(odd) - 1])
    print(ans)

if __name__ == '__main__':
    main()
