#include using namespace std; vector solve(const vector &a, const vector> &qs) { int n = a.size(); vector ds; for (int i = 1; i < n; ++i) { ds.push_back(a[i - 1] <= a[i] ? 0 : 1); } vector sum; sum.push_back(0); for (int i = 0; i < n - 1; ++i) { sum.push_back(sum[i] + ds[i]); } vector ans; for (auto q : qs) { int l, r; tie(l, r) = q; ans.push_back(sum[r] == sum[l]); } return ans; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n; cin >> n; vector a(n); // forall non-negative? non-positive? for (auto &x : a) cin >> x; int q; cin >> q; vector> qs(q); for (auto &q : qs) { int l, r; cin >> l >> r; q = make_pair(l, r); } vector xs = solve(a, qs); for (auto &x : a) x = -x; vector ys = solve(a, qs); for (int i = 0; i < q; ++i) { cout << xs[i] << ' ' << ys[i] << '\n'; } }