See the logic is suppose there are N process with each max demand D$_{di}$ ,then to avoid deadlock give all process D$_{di}$ -1 resource +1( resource to avoid deadlock) got it? not then think why it will not lead to deadlock.
So,$\sum_{i=0}^{i=n}di$ - n +1= 7
Solving it will give total demand as 16.