#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n[3], t[3];
  while (scanf("%d", &k) == 1) {
    for (int i = 0; i < 3; i++) scanf("%d", &n[i]);
    for (int i = 0; i < 3; i++) scanf("%d", &t[i]);
    deque<int> q[3];
    for (int i = 0; i < 3; i++) q[i].clear();
    int p = 0;
    while (k--) {
      for (int i = 0; i < 3; i++)
        if (q[i].size() == n[i]) {
          p = q[i].front() + t[i];
          for (int j = 0; j < 3; j++) {
            while (q[j].size() && q[j].front() + t[j] <= p) q[j].pop_front();
          }
          i = -1;
        }
      for (int i = 0; i < 3; i++) q[i].push_back(p);
    }
    printf("%d\n", p + t[0] + t[1] + t[2]);
  }
  return 0;
}
