Answer
20 people: 9.5 minutes
40 people: 39 minutes
Work Step by Step
Each handshake is a selection of 2 people from 20, with no importance in the order.
There are ${}_{20}C_{2}=\displaystyle \frac{20\times 19}{1\times 2}=190$ such selections.
Each lasting 3 seconds, the total time is:
190$\times$3=570 seconds ( 9.5 minutes)
If there were 40 people, the total number of handshakes is:
${}_{20}C_{2}=\displaystyle \frac{40\times 39}{1\times 2}=$780
Total time needed: 780$\times$3= 2340 seconds
(39 minutes)