Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/massiv-x-oxirgi-orni

Last occurrence of x

Easy 1000 ms 128 MB 27%
Share

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$).

Finding the last position of the searched element in the array

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

Sign in to submit a solution

Signing up is free and takes a minute.