it's kinda important where the holes are and whether they match up. Just like every car comes with 4 tires, that doesn't mean that ya can arbitrarily switch them from one car to another. This is a simple question easily answered if you:

a) Visit the Cooler's web site and look if the hardware provided contains the necessary adapters for your new board

or

b) Name the cooler.

 
Forget it. Store bought HP computers do not generally come with aftermarket cooling solutions= and if they do they don't ship the necessary accessories for you to change socket types.

Since you are buying a new CPU, it will come with a cooler that works with it.