#C4532. Find the First Smaller Element

    ID: 48081 Type: Default 1000ms 256MiB

Find the First Smaller Element

Find the First Smaller Element

You are given an array of integers. Your task is to determine the first element (from left to right) that is strictly smaller than the element immediately preceding it. More formally, if the array is \(a_1, a_2, \dots, a_n\), find the smallest index \(i\) (with \(2 \le i \le n\)) such that \(a_i < a_{i-1}\). If there is no such index, output \(-1\).

Note: The input array will have a length between 1 and 100, and each element is guaranteed to be between 1 and 1000 (inclusive).

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer \(n\), the number of elements in the array.
  • The second line contains \(n\) space-separated integers.

outputFormat

Output the first element which is smaller than its preceding element. If no such element exists, output \(-1\). The result should be written to stdout.

## sample
5
1 2 3 5 4
4