#include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t N, Q, i; cin >> N; vector A(N); for (i = 0; i != N; ++i) cin >> A[i]; cin >> Q; vector l(Q), r(Q); for (i = 0; i != Q; ++i) cin >> l[i] >> r[i]; set anti_f, anti_g; set::iterator itr; for (i = 0; i != N - 1; ++i) { if (A[i] > A[i + 1]) anti_f.insert(i); if (A[i] < A[i + 1]) anti_g.insert(i); } for (i = 0; i != Q; ++i) { if ((itr = anti_f.lower_bound(l[i])) != anti_f.end() && *itr < r[i]) cout << "0 "; else cout << "1 "; if ((itr = anti_g.lower_bound(l[i])) != anti_g.end() && *itr < r[i]) cout << "0\n"; else cout << "1\n"; } return 0; }