#include <bits/stdc++.h>
using namespace std;
int getCount(int n,vector<int>&arr,int k){
int count=0;
int last=-1;
int found=-1;
for(int i=0;i<n;i++){
if(arr[i]>k){
last=i;
}
if(arr[i]==k){
found=i;
}
if(last>found){
count=count+(last-found);
}
}
return count;
}
int main() {
// your code goes here
int n;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int k;
cin>>k;
cout<<"The count of subarray with maximum element k is:"<<getCount(n,v,k);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBnZXRDb3VudChpbnQgbix2ZWN0b3I8aW50PiZhcnIsaW50IGspewoJaW50IGNvdW50PTA7CglpbnQgbGFzdD0tMTsKCWludCBmb3VuZD0tMTsKCWZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGlmKGFycltpXT5rKXsKICAgICAgICAJbGFzdD1pOwogICAgICAgIH0KICAgICAgICBpZihhcnJbaV09PWspewogICAgICAgIAlmb3VuZD1pOwogICAgICAgIH0KICAgICAgICBpZihsYXN0PmZvdW5kKXsKICAgICAgICAJY291bnQ9Y291bnQrKGxhc3QtZm91bmQpOwogICAgICAgIH0KCX0KCXJldHVybiBjb3VudDsKfQogCmludCBtYWluKCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJaW50IG47CgljaW4+Pm47Cgl2ZWN0b3I8aW50PnYobik7Cglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQljaW4+PnZbaV07Cgl9CglpbnQgazsKCWNpbj4+azsKCWNvdXQ8PCJUaGUgY291bnQgb2Ygc3ViYXJyYXkgd2l0aCBtYXhpbXVtIGVsZW1lbnQgayBpczoiPDxnZXRDb3VudChuLHYsayk7CiAKCXJldHVybiAwOwp9