Travel between two islands

No attempts yetTime limit1sMemory limit16 MB

Problem

NN islands numbered 11 to NN stand in a row. No bridge connects them yet, so people can only travel by boat, and the government decided to build the N1N-1 bridges that join island ii to island i+1i+1. The bridges cannot all be built at once, so they are finished one at a time in a fixed order.

Each time a bridge is finished, the government wants two values.

  • The number of island pairs (i,j)(i, j) with i<ji < j that can reach each other.
  • The sum, over those pairs, of the smallest number of bridges you have to cross to get from island ii to island jj.

Report both values after every bridge.

Input

The first line contains the number of islands NN (2N1052 \le N \le 10^5).

Each of the next N1N-1 lines contains one integer ii (1i<N1 \le i < N), meaning that the bridge joining island ii and island i+1i+1 is built at that turn. No number appears twice.

Output

After each bridge is built, print the two values on one line, separated by a space. Print N1N-1 lines in total.