Reduce Array Function In Python