#P51656. 「LOJ」 序列查询

「LOJ」 序列查询

题目描述

参考:Codeforces 765F

给出序列 {an}\{a_n\}
给出 mm 个询问 [Li,Ri][L_i,R_i] : 询问 min{asat},s,t[Li,Ri],stmin\{|a_s-a_t|\}, s, t\in [L_i,R_i],s \not = t

输入格式

第一行一个整数 n n
第二行 n n 个整数,表示 ai a_i
第三行一个整数 mm,表示询问个数。
之后的 mm 行,每行两个正整数,表示 Li,RiL_i, R_i

输出格式

mm 行,表示询问的答案。
特别的,如果不存在答案,输出 21474836472147483647

样例

4
2 2 3 4
2
1 2
2 4
0
1

数据范围与提示

1n105,1ai109,1m3×1051\le n\le 10^5,1\le a_i \le 10^9,1\le m \le 3\times 10^5