We will use the formula Q = nl, where Q is the heat, n is the number of moles and l is the latent molar heat of fusion of water.
The formula to calculate moles is moles = mass / Mr, so n = 40 / 18 which comes out to be 2.22 moles.
Now we can calculate the heat, Q = 2.22 x 6.01. So 13.34 kJ of heat must be removed in order to freeze a tray of ice of 40 g