n birds on a tree want to learn natural numbers.
They start singing all natural numbers in the increasing order starting from 1. When a number K is sung, K birds fly away from the tree. If, at any second, the number of birds on the tree is strictly less than the number which must be sung, the birds restart the game and start singing the numbers from 1 again.
You are given an int n ? the number of birds on the tree. Taking into account that singing a number takes exactly one second, return the total time elapsed before all birds fly away.
|