#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector va(n); for (auto&& iv : va) cin >> iv; vector f(n, 0), g(n, 0); for (int i = 1; i < n; ++i) { f[i] = va[i - 1] <= va[i]; f[i] += f[i - 1]; g[i] = va[i - 1] >= va[i]; g[i] += g[i - 1]; } int q; cin >> q; stringstream ss; for (int i = 0; i < q; ++i) { int l, r; cin >> l >> r; ss << (f[r] - f[l] == r - l) << " " << (g[r] - g[l] == r - l) << "\n"; } cout << ss.str(); return 0; }