#include <bits/stdc++.h>
using namespace std;
long long b, an;
long long a[9];
long long d[100009];
long long f[100009];
int main() {
  for (int i = 0; i < 6; i++) scanf("%I64d", &a[i]);
  scanf("%I64d", &b);
  for (int i = 1; i <= b; i++) {
    scanf("%I64d", &d[i]);
    f[i] = d[i];
  }
  for (int i = 0; i < 3; i++) {
    long long k = 0, c = 0;
    while (c <= b) {
      c += a[i];
      for (int j = min(c, b); j > c - a[i]; j--) {
        if (j - a[i] >= 1)
          d[j] = max(d[j], d[j - a[i]]) + a[i + 3];
        else
          d[j] += a[i + 3];
      }
    }
  }
  for (int i = 1; i <= b; i++) an = max(an, d[i] - f[i]);
  printf("%I64d", an);
  getchar();
  getchar();
}
