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 int iinf = 1e9 + 7;
const long long linf = 1ll << 60;
const double dinf = 1e60;
template <typename T>
inline void scf(T &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) {
  scf(x);
  return scf(y);
}
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) {
  scf(x);
  scf(y);
  return scf(z);
}
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
  scf(x);
  scf(y);
  scf(z);
  return scf(w);
}
inline char mygetchar() {
  char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
template <typename T>
void chkmax(T &x, const T &y) {
  if (y > x) x = y;
  return;
}
template <typename T>
void chkmin(T &x, const T &y) {
  if (y < x) x = y;
  return;
}
const int N = 1e5 + 100;
int n, q_n;
int a[N], ans[N + N + N];
vector<pair<int, int> > q[N];
namespace seg {
struct node {
  node *l, *r;
  int val;
  vector<pair<int, int> > all;
} * rt;
int a, b, ans;
inline void build(node *&cur, const int &l, const int &r) {
  cur = new node;
  cur->l = cur->r = 0;
  cur->val = iinf;
  cur->all.clear();
  if (l == r) {
    cur->all.push_back({::a[l], 0});
    cur->all.push_back({iinf, 0});
    return;
  }
  int mid = l + r >> 1;
  build(cur->l, l, mid);
  build(cur->r, mid + 1, r);
  vector<pair<int, int> > &L = cur->l->all, &R = cur->r->all;
  int cnt = 0, i = 0, j = 0, sl = (int)L.size() - 1, sr = (int)R.size() - 1;
  for (int _ = (sl + sr) - 1; _ >= 0; --_)
    cur->all.push_back(((L[i].first < R[j].first)
                            ? make_pair(L[i++].first, cnt++)
                            : make_pair(R[j++].first, cnt)));
  cur->all.push_back({iinf, cnt});
  return;
}
inline void modify(node *&cur, const int &l, const int &r, const int &p) {
  if (r <= a) return;
  if (l == r) {
    chkmin(cur->val, abs(::a[l] - b));
    chkmin(ans, cur->val);
    return;
  }
  if (ans < iinf) {
    int tmp = iinf;
    if (p < (int)cur->all.size() - 1) chkmin(tmp, cur->all[p].first - b);
    if (p) chkmin(tmp, b - cur->all[p - 1].first);
    if (tmp >= ans) return;
  }
  int mid = l + r >> 1;
  modify(cur->l, l, mid, cur->all[p].second);
  modify(cur->r, mid + 1, r, p - cur->all[p].second);
  chkmin(cur->val, ans);
  return;
}
inline void query(node *&cur, const int &l, const int &r) {
  if (a <= l && r <= b) return chkmin(ans, cur->val);
  int mid = l + r >> 1;
  if (a <= mid) query(cur->l, l, mid);
  if (b > mid) query(cur->r, mid + 1, r);
  return;
}
void out(node *rt, int l, int r) {
  printf("%d %d:\t%d\t", l, r, rt->val);
  for (auto a : rt->all) printf("{%d,%d} ", a.first, a.second);
  puts("");
  if (l == r) return;
  int mid = l + r >> 1;
  out(rt->l, l, mid);
  out(rt->r, mid + 1, r);
  return;
}
inline void modify(const int &i) {
  a = i;
  b = ::a[i];
  ans = iinf;
  return modify(
      rt, 1, n,
      lower_bound(rt->all.begin(), rt->all.end(), make_pair(::a[i], 0)) -
          rt->all.begin());
}
inline int query(const int &l, const int &r) {
  a = l;
  b = r;
  ans = iinf;
  query(rt, 1, n);
  return ans;
}
void build() { return build(rt, 1, n); }
inline void output() {
  out(rt, 1, n);
  return;
}
}  // namespace seg
void MEI() {
  scf(n);
  for (int i = (1); i <= (n); ++i) scf(a[i]);
  seg::build();
  scf(q_n);
  for (int i = (1); i <= (q_n); ++i) {
    int l, r;
    scf(l, r);
    q[l].push_back({i, r});
  }
  return;
}
void ZI() {
  for (int i = (n); i >= (1); --i) {
    seg::modify(i);
    for (auto x : q[i]) ans[x.first] = seg::query(i, x.second);
  }
  for (int i = (1); i <= (q_n); ++i) printf("%d\n", ans[i]);
  return;
}
int main() {
  MEI();
  ZI();
  return 0;
}
