Could someone assist me in setting up this equation? Thanks!!

A block of mass 2 kg attached to a spring lies on a flat surface. When the block is pulled 5 cm to the right a force with a magnitude of 340 N is need to hold it in place. What is the work done by the spring when the block moves from x = 8 cm to x = 12 cm. Express your answer in joules.