{"trustable":false,"sections":[{"title":"Description","value":{"format":"MD","content":"每天,农夫 John 的 $n \\ (1\\le n\\le 5\\times 10^4)$ 头牛总是按同一序列排队。\n\n有一天, John 决定让一些牛们玩一场飞盘比赛。他准备找一群在队列中位置连续的牛来进行比赛。但是为了避免水平悬殊,牛的身高不应该相差太大。John 准备了 $q \\ (1\\le q\\le 1.8\\times10^5)$ 个可能的牛的选择和所有牛的身高 $h_i \\ (1\\le h_i\\le 10^6)$。他想知道每一组里面最高和最低的牛的身高差。"}},{"title":"Input","value":{"format":"MD","content":"第一行两个数 $n,q$。\n\n接下来 $n$ 行,每行一个数 $h_i$。\n\n再接下来 $q$ 行,每行两个整数 $a$ 和 $b$,表示询问第 $a$ 头牛到第 $b$ 头牛里的最高和最低的牛的身高差。\n"}},{"title":"Output","value":{"format":"MD","content":"输出共 $q$ 行,对于每一组询问,输出每一组中最高和最低的牛的身高差。"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6 3\n1\n7\n3\n4\n2\n5\n1 5\n4 6\n2 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n3\n0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}