Artsem is on vacation and wants to buy souvenirs for his two teammates. There are n souvenir shops along the street. In i-th shop Artsem can buy one souvenir for ai dollars, and he cannot buy more than one souvenir in one shop. He doesn't want to introduce envy in his team, so he wants to buy two souvenirs with least possible difference in price.

Artsem has visited the shopping street m times. For some strange reason on the i-th day only shops with numbers from li to ri were operating (weird? yes it is, but have you ever tried to come up with a reasonable legend for a range query problem?). For each visit, Artsem wants to know the minimum possible difference in prices of two different souvenirs he can buy in the opened shops.

In other words, for each Artsem's visit you should find the minimum possible value of |as - at| where li ≤ s, t ≤ ri, s ≠ t.

Input

The first line contains an integer n (2 ≤ n ≤ 105).

The second line contains n space-separated integers a1, ..., an (0 ≤ ai ≤ 109).

The third line contains the number of queries m (1 ≤ m ≤ 3·105).

Next m lines describe the queries. i-th of these lines contains two space-separated integers li and ri denoting the range of shops working on i-th day (1 ≤ li < ri ≤ n).

Output

Print the answer to each query in a separate line.

Example

Input

8
3 1 4 1 5 9 2 6
4
1 8
1 3
4 8
5 7


Output

0
1
1
3
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
long long n, m, a[200005], mi, ans[400005];
struct node {
  long long minn;
} tree[400005];
struct Node {
  long long l, r, id;
  bool operator<(const Node &a) const { return r < a.r; }
} q[400005];
long long read() {
  long long f = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    f = f * 10 + ch - '0';
    ch = getchar();
  }
  return f * w;
}
vector<long long> v[400005];
void build(long long tr, long long l, long long r) {
  for (long long i = l; i <= r; i++) v[tr].push_back(a[i]);
  sort(v[tr].begin(), v[tr].end());
  tree[tr].minn = inf;
  if (l == r) return;
  long long mid = (l + r) / 2;
  build(tr * 2, l, mid), build(tr * 2 + 1, mid + 1, r);
}
void update(long long tr, long long stdl, long long stdr, long long pos,
            long long k) {
  if (stdr <= pos) {
    vector<long long>::iterator it = upper_bound(v[tr].begin(), v[tr].end(), k);
    if (it != v[tr].end()) tree[tr].minn = min(tree[tr].minn, *it - k);
    if (it != v[tr].begin()) tree[tr].minn = min(tree[tr].minn, k - *(it - 1));
    if (mi <= tree[tr].minn) return;
    if (stdl == stdr) {
      mi = min(mi, tree[tr].minn);
      return;
    }
  }
  long long mid = (stdl + stdr) / 2;
  if (pos > mid) update(tr * 2 + 1, mid + 1, stdr, pos, k);
  update(tr * 2, stdl, mid, pos, k);
  tree[tr].minn =
      min(tree[tr].minn, min(tree[tr * 2].minn, tree[tr * 2 + 1].minn));
  mi = min(mi, tree[tr].minn);
}
long long query(long long tr, long long stdl, long long stdr, long long l,
                long long r) {
  if (l > stdr || r < stdl) return inf;
  if (l <= stdl && r >= stdr) return tree[tr].minn;
  long long mid = (stdl + stdr) / 2;
  return min(query(tr * 2, stdl, mid, l, r),
             query(tr * 2 + 1, mid + 1, stdr, l, r));
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  build(1, 1, n);
  m = read();
  for (long long i = 1; i <= m; i++) {
    q[i].l = read(), q[i].r = read();
    q[i].id = i;
  }
  sort(q + 1, q + 1 + m);
  for (long long pos = 1, i = 2; i <= n; i++) {
    mi = inf;
    update(1, 1, n, i - 1, a[i]);
    for (; pos <= m && q[pos].r <= i; pos++) {
      ans[q[pos].id] = query(1, 1, n, q[pos].l, i);
    }
  }
  for (long long i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
