#include <bits/stdc++.h>
using namespace std;
queue<int> Q[3];
int main() {
  int k, n[3], t[3];
  scanf("%d%d%d%d%d%d%d", &k, &n[0], &n[1], &n[2], &t[0], &t[1], &t[2]);
  int now = 0;
  for (int i = 0; i < (k); ++i) {
    bool ok = 0;
    while (!ok) {
      ok = 1;
      for (int j = 0; j < (3); ++j) {
        if (Q[j].size() == n[j]) {
          ok = 0;
          break;
        }
      }
      if (ok) break;
      ++now;
      int z = now;
      for (int j = 0; j < (3); ++j) {
        while (!Q[j].empty() && Q[j].front() == z) Q[j].pop();
        z += t[j];
      }
    }
    int z = now;
    for (int j = 0; j < (3); ++j) {
      z += t[j];
      Q[j].push(z);
    }
  }
  int ret = now;
  while (!Q[2].empty()) {
    ret = max(ret, Q[2].front());
    Q[2].pop();
  }
  printf("%d\n", ret);
  return 0;
}
