#include using namespace std; int main() { int n; cin>>n; long long a[n]; for (int i=0; i>a[i]; vector > inc; int i = 0; while (i < n) { int s = i; while (i < n - 1 && a[i] <= a[i+1]) { ++i; } inc.emplace_back(s, i - s + 1); if (s == i) { ++i; } } vector > dec; i = 0; while (i < n) { int s = i; while (i < n - 1 && a[i] >= a[i+1]) { ++i; } dec.emplace_back(s, i - s + 1); if (s == i) { ++i; } } int q; cin>>q; for (i=0; i>l>>r; auto it = upper_bound(inc.begin(), inc.end(), make_pair(l, INT_MAX)); int f = 0; if (it != inc.begin()) { --it; int s = (*it).first; int len =(*it).second; if (r <= s + len - 1) { f = 1; } } it = upper_bound(dec.begin(), dec.end(), make_pair(l, INT_MAX)); int g = 0; if (it != dec.begin()) { --it; int s = (*it).first; int len =(*it).second; if (r <= s + len - 1) { g = 1; } } cout<