Recovery through preemption: After processes P2 and P3 complete, (till here it was safe, so no need to do anything extra). Then process P1 can be forced to preempt 1 unit of RS3. This will make A=(0 2 1 3 2), and allow process P4 to complete. Once P4 completes and release its resources P1 may complete.
Recovery through rollback: Rollback P1 to the state check pointed before it acquired RS3.
Recovery through killing processes: Kill P1.
Ref: Tanenbaum Solution Manual