In case the annual cashflows are not the same, the formula is still valid.
Suppose the same project is costing $200.000, but now the annual cashflows are: $30.000 (yr 1), $40.000 (yr 2), $50.000 (yr 3), $40.000 (yr 4), $20.000 (yr 5), $20.000 (yr 6), and $50.000 (yr 7).
After 6 years the total of all cash inflows equals the costs (investments) in the project. Therefore the Payback Period of our project is 6 years.