Since the average age of finance department increased by 1, the total age became 31*20=620.
Initially total age= 30*20=600.
Therefore there is a net increase of age by 20 years. Hence the decrease in total age of Marketting department will be also 20. But since average age of marketing department is not changed , therefore-
total age after transfer from marketting to HR dept= 29*35=1015.
Initial total= 30*35=1050.
Decrease in total due to transfer from marketing to Finance dept=20. But total has to be maintained at 1015.
Therefore HR dept age total must have been increased by 35-20=15.
Hence new average of HR= 45*5+15=240.
Average = 240/6=40 (ANSWER)