cho.sh
Notes
Loading...

Work Process

Time limit

2s

Memory limit

128 MB

Problem

A company's work is processed from the bottom of its organization chart upward. Terminal employees perform their tasks first, and an employee may start only after every employee below them has finished. The whole process ends when the president finishes their task. Every employee's task takes exactly 1 unit of time from start to finish.

Every employee except the president has exactly one direct supervisor. The company wants to reduce its staff. A task belonging to a removed employee may be performed by any remaining employee, and one employee can perform only one task at a time. Remaining employees may perform tasks for other positions freely, but the total completion time must not become longer than before any employees were removed.

Given the direct-supervisor relationship, find the original minimum completion time and the maximum number of employees that can be removed while preserving that time.

Input

The first line contains an integer N(1 <= N <= 100,000), the number of employees. The next N lines give, in order, the direct supervisor number of employees 1, 2, ..., N. For the president, -1 is given.

Output

Print the minimum completion time needed when all employees are present on the first line. On the second line, print the maximum number of employees that can be removed while preserving that time.

Hint

One optimal schedule can be viewed as follows.

  • Time 0-1: four remaining employees simultaneously perform the tasks of employees 4, 5, 6, and 7.
  • Time 1-2: then two employees perform the tasks of employees 2 and 3.
  • Time 2-3: finally, one employee performs the task of employee 1.