#include using namespace std; long long n, p, m = 0; long long u[200001], v[200001]; int main(){ cin >> n; for(long long i = 0; i < n; i++){ cin >> p; u[p] = i + 1; } for(long long i = 1; i < n; i++){ v[i] = v[i - 1] + u[i]; m = max(m, v[i] - u[i + 1]); } cout << m << endl; }