#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void shelby() {
int n;
cin >> n;
vector<int> v(n);
cinv(v)
auto calc = [&]()-> vector<int> {
vector<int> ret(n);
ordered_set<int> o;
for (int i = 0; i < n; ++i) {
if (o.order_of_key(v[i] + 1) >= abs(v[i])) ret[i] = 1;
debug(o.order_of_key(v[i]+1), v[i], abs(v[i]), ret[i]);
debug(o.order_of_key(v[i]+1)>=v[i]);
o.insert(v[i]);
}
debug(ret);
return ret;
};
vector<int> ans = calc();
for (auto &it: v) it *= -1;
reverse(v.begin(), v.end());
debug(v);
vector<int> ans2 = calc();
reverse(ans2.begin(), ans2.end());
int cnt = 0;
for (int i = 0; i < n; ++i) cnt += (ans[i] | ans2[i]);
cout << cnt << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}