Mathematically
To calculate the total demand curve (aggregate demand has a different meaning), you just need to ask yourself that for each price, how many units will be demanded.
You have three groups:
- A. 20 people, perfectly elastic at $p = 2$. This group will buy 20 units as long as $p \leq 2$.
- B. 40 people, perfectly elastic at $p = 4$. This group will buy 40 units as long as $p \leq 4$.
- C. 50 people, perfectly inelastic. This group will buy 50 units no matter what.
Mathematically,
$$A(p) = \begin{cases} 20 & \text{if $p \leq 2$} \\ 0 & \text{otherwise}\end{cases},\quad
B(p) = \begin{cases} 40 & \text{if $p \leq 4$} \\ 0 & \text{otherwise}\end{cases},\quad
C(p) = 50$$
Total demand is just a function of $p$: $Q(p) = A(p) + B(p) + C(p)$.
If we start at $p = 1$, what's $A(1) + B(1) + C(1)$? Do this for all prices, and you'll get the total demand curve.
Graphically
You could also do this graphically... draw up the demand curve (would look like a rectangle) for each group. The total demand curve will just be the horizontal stack of these rectangles.