#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > pq;
int main() {
  int k, n1, n2, n3, t1, t2, t3, k1, k2, k3;
  scanf("%d %d %d %d %d %d %d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  k1 = k;
  k2 = k3 = 0;
  for (int tt = 0;; tt = -pq.top().first) {
    while (!pq.empty() && pq.top().first == -tt) {
      pair<int, int> p = pq.top();
      pq.pop();
      if (p.second == 1)
        k2++;
      else if (p.second == 2)
        k3++;
      else
        n3++;
    }
    while (n3 && k3) {
      n3--;
      k3--;
      n2++;
      pq.push(make_pair(-tt - t3, 3));
    }
    while (n2 && k2) {
      n2--;
      k2--;
      n1++;
      pq.push(make_pair(-tt - t2, 2));
    }
    while (n1 && k1) {
      n1--;
      k1--;
      pq.push(make_pair(-tt - t1, 1));
    }
    if (pq.empty()) {
      printf("%d\n", tt);
      break;
    }
  }
  return 0;
}
