There's the potential energy due to the force on the nail. This potential energy was created when the magnet was made and you change it when you move the magnet near the nail. When the nail sticks to the magnet, going against the force of gravity, the magnetic potential energy is converted into gravitational potential energy.