// yuki 905 Sorted // 2019.10.11 bal4u #include #include #include #include typedef long long ll; typedef unsigned long long ull; #if 1 int getchar_unlocked(void); int putchar_unlocked(int c); #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 整数の入力 int n = 0, c = gc(); while (isspace(c)) c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } ll inL() { // long long 整数の入力 ll n = 0; int c = gc(); while (isspace(c)) c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } void out(int n) { // 整数の表示 int i; char b[30]; if (!n) pc('0'); else { if (n < 0) pc('-'), n = -n; i = 0; while (n) b[i++] = n % 10 + '0', n /= 10; while (i--) pc(b[i]); } pc('\n'); } int a[100005]; int b[100005]; int main() { int i, N, l, r, Q; ll A, A0; N = in(); A0 = inL(); for (i = 1; i < N; i++) { A = inL(); if (A0 < A) a[i] = a[i-1], b[i] = b[i-1]+1; else if (A0 > A) a[i] = a[i-1]+1, b[i] = b[i-1]; else a[i] = a[i-1], b[i] = b[i-1]; A0 = A; } Q = in(); while (Q--) { l = in(), r = in(); pc('0'+(a[r]==a[l])), pc(' '), pc('0'+(b[r]==b[l])), pc('\n'); } return 0; }