#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int x[n];
int counter = 0; // количество перемещений
for (int i = 0; i < n; i++){
cin >> x[i];
}
int first = x[0]; // первый по порядку элемент
for (int i = 0; i < n - 1; i++) {
int min = i; // индекс минимального элемента
for (int j = i + 1; j < n; j++) {
if (x[j] < x[min]) min = j;
}
if((x[i] == first || x[min] == first) && x[i] != x[min]) counter++;
swap(x[i], x[min]);
}
cout << counter;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbjsKCWNpbiA+PiBuOwoJaW50IHhbbl07CglpbnQgY291bnRlciA9IDA7IC8vINC60L7Qu9C40YfQtdGB0YLQstC+INC/0LXRgNC10LzQtdGJ0LXQvdC40LkKCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKCQljaW4gPj4geFtpXTsKCX0KCWludCBmaXJzdCA9IHhbMF07IC8vINC/0LXRgNCy0YvQuSDQv9C+INC/0L7RgNGP0LTQutGDINGN0LvQtdC80LXQvdGCCglmb3IgKGludCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHsKCQlpbnQgbWluID0gaTsgLy8g0LjQvdC00LXQutGBINC80LjQvdC40LzQsNC70YzQvdC+0LPQviDRjdC70LXQvNC10L3RgtCwCgkJZm9yIChpbnQgaiA9IGkgKyAxOyBqIDwgbjsgaisrKSB7CgkJCWlmICh4W2pdIDwgeFttaW5dKSBtaW4gPSBqOwoJCX0KCQlpZigoeFtpXSA9PSBmaXJzdCB8fCB4W21pbl0gPT0gZmlyc3QpICYmIHhbaV0gIT0geFttaW5dKSBjb3VudGVyKys7CgkJc3dhcCh4W2ldLCB4W21pbl0pOwoJfQoJY291dCA8PCBjb3VudGVyOwoJcmV0dXJuIDA7Cn0=