I suppose this is the formula for min. no. of processes required for deadlock. For this, we assume the worst case and this happens when all but 1 required resources are taken by all the processes.
i.e., total allocated = total max need - n
If we have one more resource, one process can be finished and this results in more processes getting finished and there won't be a deadlock. So, for deadlock,
max. no. of resources = total max. need - n
or
total max. need = n + no. of resources