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>
#pragma GCC optimize "-oFast"
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct flusher {
  ~flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
const int MAXN = 300228;
const int INF = 1000000228;
int n;
vector<pair<long long, int> > st;
vector<pair<int, int> > go[MAXN];
long long a[MAXN];
long long ans[MAXN];
int mx[MAXN * 4];
long long mn[MAXN * 4];
long long dd[MAXN * 4];
void build(int v, int tl, int tr) {
  mn[v] = INF;
  mx[v] = -1;
  dd[v] = INF;
  if (tl + 1 == tr) {
    return;
  }
  int m = (tl + tr) >> 1;
  build((v << 1) + 1, tl, m);
  build((v << 1) + 2, m, tr);
}
int getMax(int v, int tl, int tr, int l, int r) {
  if (r <= tl || tr <= l) {
    return -1;
  }
  if (l <= tl && tr <= r) {
    return mx[v];
  }
  int m = (tl + tr) >> 1;
  return max(getMax((v << 1) + 1, tl, m, l, r),
             getMax((v << 1) + 2, m, tr, l, r));
}
long long get(int v, int tl, int tr, int x) {
  if (tl + 1 == tr) {
    return mn[v];
  }
  int m = (tl + tr) >> 1;
  if (x < m) {
    return min(get((v << 1) + 1, tl, m, x), dd[v]);
  } else {
    return min(get((v << 1) + 2, m, tr, x), dd[v]);
  }
}
void updateMin(int v, int tl, int tr, int l, int r, long long x) {
  if (r <= tl || tr <= l) {
    return;
  }
  if (l <= tl && tr <= r) {
    dd[v] = min(dd[v], x);
    mn[v] = min(mn[v], x);
    return;
  }
  int m = (tl + tr) >> 1;
  updateMin((v << 1) + 1, tl, m, l, r, x);
  updateMin((v << 1) + 2, m, tr, l, r, x);
  mn[v] = min(mn[(v << 1) + 1], mn[(v << 1) + 2]);
  mn[v] = min(mn[v], dd[v]);
}
void updateMax(int v, int tl, int tr, int x, int y) {
  mx[v] = max(mx[v], y);
  if (tl + 1 == tr) {
    return;
  }
  int m = (tl + tr) >> 1;
  if (x < m) {
    updateMax((v << 1) + 1, tl, m, x, y);
  } else {
    updateMax((v << 1) + 2, m, tr, x, y);
  }
}
int main() {
  n = readInt();
  for (int i = 0; i < n; i++) {
    a[i] = readInt();
    st.push_back(make_pair(a[i], i));
  }
  sort((st).begin(), (st).end());
  int m = readInt();
  for (int i = 0; i < m; ++i) {
    int l = readInt(), r = readInt();
    l--, r--;
    go[r].push_back(make_pair(l, i));
  }
  build(0, 0, n);
  for (int i = 0; i < n; i++) {
    int pl =
        lower_bound((st).begin(), (st).end(), make_pair(a[i], i)) - st.begin();
    long long now = INF;
    while (true) {
      int x =
          lower_bound((st).begin(), (st).end(), make_pair(a[i] + now + 1, 0)) -
          st.begin();
      if (pl + 1 >= x) {
        break;
      }
      x = getMax(0, 0, n, pl + 1, x);
      if (x == -1) {
        break;
      }
      long long d = a[x] - a[i];
      updateMin(0, 0, n, 0, x + 1, d);
      if (d == 0) {
        break;
      }
      now = d / 2;
    }
    now = INF;
    while (true) {
      int x = lower_bound((st).begin(), (st).end(), make_pair(a[i] - now, 0)) -
              st.begin();
      if (x >= pl) {
        break;
      }
      x = getMax(0, 0, n, x, pl);
      if (x == -1) {
        break;
      }
      long long d = a[i] - a[x];
      updateMin(0, 0, n, 0, x + 1, d);
      if (d == 0) {
        break;
      }
      now = d / 2;
    }
    updateMax(0, 0, n, pl, i);
    for (auto q : go[i]) {
      ans[q.second] = get(0, 0, n, q.first);
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
