Be very careful with HP machines (and some Dell's as I've learned to my chagrin) and power supplies. HP has in the past (and maybe still does) used power supply connectors that are very nonstandard. On the bright side they use a different size, so any question of whether they put the pins in the right place is moot, so you need not worry about accidentally burning out the motherboard.
The problem is that a standard ATX power supply will not necessarily work in an HP machine. You should make sure that the motherboard connector fits before purchasing a given power supply. I recommend measuring the motherboard connector with a ruler and taking that measurement and ruler to the computer shop. If is the same, you win!. Otherwise you'll have to get one from HP if you can, or (possibly) get an adapter. Those can be hard to find though.