//#pragma GCC optimize("O3")
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
// using ll = __int128;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main() {
ios_base::sync_with_stdio(false);
cout.tie(nullptr); cin.tie(nullptr);
ll n; cin >> n;
vector<ll> h(n, 0);
for (int i = 0; i < n; i++) cin >> h[i];
vector<vector<ll>> gr(n, vector<ll> (0, 0));
for (int i = 0; i < n; i++) {
ll up = -1e18;
ll down = 1;
for (int j = i + 1; j < n; j++) {
ll x = j - i;
ll y = h[j] - h[i];
if (y * down >= up * x) {
gr[i].push_back(j);
up = y;
down = x;
}
}
}
int q; cin >> q;
for (int i = 0; i < q; i++) {
int l, r; cin >> l >> r; l--; r--;
ll now = l;
ll ans = 0;
if (l == r) {
cout << 0 << '\n';
continue;
}
while (1) {
ll up = -1e18;
ll down = 1;
ll best = now + 1;
for (int j = now + 1; j <= r; j++) {
ll x = j - now;
ll y = h[j] - h[now];
if (y * down >= up * x) {
best = j;
up = y;
down = x;
}
if (best == r) {
ans++;
break;
}
}
if (best == r) break;
ans++;
now = best;
}
cout << ans << '\n';
}
}