def main():
    n = int(input())
    a = list(map(int, input().split()))
    odd = sorted([x for x in a if x % 2 == 1], reverse=True)
    even = sorted([x for x in a if x % 2 == 0], reverse=True)
    if abs(len(odd)-len(even)) < 2:
        print(0)
    else:
        if len(odd) > len(even):
            print(sum(odd[len(even)+1:]))
        else:
            print(sum(even[len(odd)+1:]))


if __name__ == '__main__':
    main()
