~/algor $ cat problems/massiv-x-oxirgi-orni
Last occurrence of x
Easy
1000 ms
128 MB
27%
A positive integer $n$, an array of $n$ integers and an integer $x$ are given. Determine the position at which the number $x$ occurs in the array for the last time (indices start from $1$; if it is not in the array, print $-1$).
Input
The first line contains a positive integer $n$. The second line contains $n$ integers. The third line contains $x$.
Output
One integer — the position of the last occurrence or $-1$.
Note
$1 \le n \le 10^{4}$
$-1000 \le a_{i}, x \le 1000$
Examples
Input #1
6 4 7 1 7 2 7 7
Output #1
6
Input #2
4 5 5 1 2 5
Output #2
2