Solution (source code)

= Solution

For the marked subset, $\langle e_0|A_1\rangle=S_1/\sqrt N$ by the same summation of the individual <inner products>. Consequently
$$
W|A_1\rangle=2|e_0\rangle\frac{S_1}{\sqrt N}-|A_1\rangle=\boxed{\frac{2S_1}N|J\rangle-|A_1\rangle.}
$$
The cardinality is $S_1$ here. Its sign will reverse when this expression is used for the oracle's negative marked component.