#C4510. Mountain Peaks

    ID: 48057 Type: Default 1000ms 256MiB

Mountain Peaks

Mountain Peaks

You are given a sequence of integers representing the heights of a series of mountains. A mountain is considered a peak if it is strictly taller than its adjacent mountains. More specifically, for a given mountain with height \(h_i\):

  • If \(i = 0\) (first mountain), it is a peak if \(h_0 > h_1\).
  • If \(i = n-1\) (last mountain), it is a peak if \(h_{n-1} > h_{n-2}\).
  • For all other mountains, it is a peak if \(h_i > h_{i-1}\) and \(h_i > h_{i+1}\).

Note that if there is only one mountain, it is considered a peak by definition.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  1. The first line contains a single integer \(n\) which represents the number of mountains.
  2. The second line contains \(n\) space-separated integers which represent the heights of the mountains.

outputFormat

Output the indices of all peaks in one line, separated by a single space. The indices should be in increasing order.

## sample
5
1 3 2 4 2
1 3