For completeness, in the specific case of your array A always containing only zeroes or ones as it does in your example, you can simply multiply A and B:
A
B
A *= B