After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th string produces the note a_{i} + j.

Tayuya wants to play a melody of n notes. Each note can be played on different string-fret combination. The easiness of performance depends on the difference between the maximal and the minimal indices of used frets. The less this difference is, the easier it is to perform the technique. Please determine the minimal possible difference.

For example, if a = [1, 1, 2, 2, 3, 3], and the sequence of notes is 4, 11, 11, 12, 12, 13, 13 (corresponding to the second example), we can play the first note on the first string, and all the other notes on the sixth string. Then the maximal fret will be 10, the minimal one will be 3, and the answer is 10 - 3 = 7, as shown on the picture.

<image>

Input

The first line contains 6 space-separated numbers a_{1}, a_{2}, ..., a_{6} (1 ≤ a_{i} ≤ 10^{9}) which describe the Tayuya's strings.

The second line contains the only integer n (1 ≤ n ≤ 100 000) standing for the number of notes in the melody.

The third line consists of n integers b_{1}, b_{2}, ..., b_{n} (1 ≤ b_{i} ≤ 10^{9}), separated by space. They describe the notes to be played. It's guaranteed that b_i > a_j for all 1≤ i≤ n and 1≤ j≤ 6, in other words, you can play each note on any string.

Output

Print the minimal possible difference of the maximal and the minimal indices of used frets.

Examples

Input


1 4 100 10 30 5
6
101 104 105 110 130 200


Output


0


Input


1 1 2 2 3 3
7
13 4 11 12 11 13 12


Output


7

Note

In the first sample test it is optimal to play the first note on the first string, the second note on the second string, the third note on the sixth string, the fourth note on the fourth string, the fifth note on the fifth string, and the sixth note on the third string. In this case the 100-th fret is used each time, so the difference is 100 - 100 = 0.

<image>

In the second test it's optimal, for example, to play the second note on the first string, and all the other notes on the sixth string. Then the maximal fret will be 10, the minimal one will be 3, and the answer is 10 - 3 = 7.

<image>
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
long long mpow(long long base, long long exp);
long long power(long long a, long long b);
const long long mod = 1e9 + 7;
struct node {
  set<int> s;
};
struct segTree {
  int arr[2001];
  int res[8003];
  int NO_OPERATION = 0;
  void init(int x, int lo, int hi) {
    if (lo == hi) {
      res[x] = arr[lo];
      return;
    }
    int mid = (lo + hi) / 2;
    init(2 * x, lo, mid);
    init(2 * x + 1, mid + 1, hi);
    update_point(x);
  }
  long long merge_results(long long a, long long b) { return a + b; }
  int get_sum(int x, int lo, int hi, int l, int r) {
    if (lo >= l && hi <= r) return res[x];
    if (lo > r || hi < l) return 0;
    int mid = (lo + hi) / 2;
    return get_sum(2 * x, lo, mid, l, r) +
           get_sum(2 * x + 1, mid + 1, hi, l, r);
  }
  void point_modify(int x, int lo, int hi, int pos, long long val) {
    if (lo == hi) {
      res[x] = val;
      return;
    }
    int mid = (lo + hi) / 2;
    if (pos <= mid)
      point_modify(2 * x, lo, mid, pos, val);
    else
      point_modify(2 * x + 1, mid + 1, hi, pos, val);
    update_point(x);
  }
  void update_point(int x) { res[x] = res[2 * x] + res[2 * x + 1]; }
  int query(int x, int lo, int hi, int l, int r) {
    if (lo >= l && hi <= r) return res[x];
    int mid = (hi + lo) / 2;
    int res;
    if (r <= mid)
      res = query(2 * x, lo, mid, l, r);
    else if (l > mid)
      res = query(2 * x + 1, mid + 1, hi, l, r);
    else
      res = merge_results(query(2 * x, lo, mid, l, r),
                          query(2 * x + 1, mid + 1, hi, l, r));
    return res;
  }
};
struct FenwickTree {
  int arr[100];
  int n;
  void update(int i, int delta) {
    while (i <= n) {
      arr[i] += delta;
      i = i + (i & (-i));
    }
  }
  int sum(int i) {
    if (i == 0) return 0;
    int res = 0;
    while (i > 0) {
      res = res + arr[i];
      i -= (i & (-i));
    }
    return res;
  }
};
struct dsu {
  int par[1001];
  int size_set[1001];
  int get_par(int u) {
    vector<int> temp;
    while (par[u] != u) {
      temp.push_back(u);
      u = par[u];
    }
    for (int i : temp) par[i] = u;
    return u;
  }
  void union_set(int a, int b) {
    a = get_par(a);
    b = get_par(b);
    if (a == b) return;
    if (size_set[a] < size_set[b]) {
      int temp = a;
      a = b;
      b = temp;
    }
    par[b] = a;
    size_set[a] += size_set[b];
  }
};
void solve() {
  long long a[6];
  for (int i = 0; i < 6; i++) cin >> a[i];
  int n;
  cin >> n;
  int b[n];
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<pair<long long, long long> > temp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      temp.push_back(make_pair(b[i] - a[j], i));
    }
  }
  int vis[n];
  for (int i = 0; i < n; i++) vis[i] = 0;
  sort(temp.begin(), temp.end());
  set<int> s;
  int pos = -1;
  long long res = LLONG_MAX;
  pair<int, int> prev;
  for (int i = 0; i < temp.size(); i++) {
    pair<int, int> p = temp[i];
    int v = p.first;
    int idx = p.second;
    s.insert(idx);
    vis[idx] += 1;
    if (s.size() == n) {
      pos = i;
      break;
    }
  }
  res = min(res, temp[pos].first - temp[0].first);
  int pr = 0;
  while (vis[temp[pr].second] > 1) {
    vis[temp[pr].second]--;
    pr++;
  }
  res = min(res, temp[pos].first - temp[pr].first);
  for (int i = pos + 1; i < temp.size(); i++) {
    int idx = temp[i].second;
    vis[idx]++;
    while (vis[temp[pr].second] > 1 && pr <= i) {
      vis[temp[pr].second]--;
      pr++;
    }
    res = min(res, temp[i].first - temp[pr].first);
  }
  cout << res << "\n";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long mpow(long long base, long long exp) {
  base %= mod;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b % 2 == 0) {
      b /= 2;
      a = a * a;
    } else {
      res = res * a;
      b--;
    }
  }
  return res;
}
