cho.sh
Notes
Loading...

Trophy Display

Time limit

2s

Memory limit

128 MB

Problem

Minsik has won many robot competitions with his team, so his home has many trophies. He placed the trophies in a single row on a shelf, ordered from left to right. When someone opens the door to his room, they first see the shelf from the left. A taller trophy in front can hide shorter trophies behind it.

From a given direction, a trophy is visible only if every trophy before it from that direction is shorter than it. Minsik can also rotate the shelf 180 degrees and view the same row from the right.

Given the trophy heights from left to right, determine how many trophies are visible from the left and how many are visible from the right.

Input

The first line contains the number of trophies, N (1 ≤ N ≤ 50). Each of the next N lines contains one trophy height, listed from the leftmost trophy to the rightmost trophy. Every height is a positive integer at most 100.

Output

Print the number of trophies visible from the left on the first line. Print the number of trophies visible from the right on the second line.