# In the Bernstein-Vazirani algorithm, what is the use of the second Hadamard gate?

In the Bernstein-Vazirani algorithm, what is the use of the second Hadamard gate? What happens if I remove it? Would the algorithm works fine? I read something about it closing the interference.

$$\frac{1}{\sqrt{2^{n}}}\sum_{x=0}^{2^n-1} (-1)^{f(x)} |x\rangle.$$
Although the phase $$(-1)^{f(x)}$$ is correct, the the probability (the squared amplitude) is uniformly distributed over each basis state. Thus without the second Hadamard gates you would not learning anything about $$f(x)$$, and your algorithm would not work.