#include #define rep(i,n) for(int i=0;i<(n);++i) using namespace std; typedef long long ll; typedef pair P; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; int q; cin >> q; vector

l(q); vector

query(q); rep(i, q) cin >> l[i].first >> l[i].second; rep(i, q) { vector res; for (int j = l[i].first; j <= l[i].second; ++j) { res.push_back(a[j]); } vector sol=res; sort(sol.begin(), sol.end()); if (sol == res) query[i].first = 1; else query[i].first = 0; reverse(sol.begin(), sol.end()); if (sol == res) query[i].second = 1; else query[i].second = 0; } rep(i, q) cout << query[i].first << ' ' << query[i].second << endl; return 0; }