#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  scanf("%d %d %d %d %d %d %d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  vector<int> W, D, F;
  int rsp = -1;
  for (int i = (0); i < (k); ++i) {
    if (W.size() < n1 && D.size() < n2 && F.size() < n3) {
      W.push_back(t1);
      D.push_back(t1 + t2);
      F.push_back(t1 + t2 + t3);
      rsp = t1 + t2 + t3;
    } else {
      int start = 0;
      if (W.size() >= n1) start = max(start, W[W.size() - n1]);
      if (D.size() >= n2) start = max(start, D[D.size() - n2] - t1);
      if (F.size() >= n3) start = max(start, F[F.size() - n3] - t1 - t2);
      W.push_back(start + t1);
      D.push_back(start + t1 + t2);
      F.push_back(start + t1 + t2 + t3);
      rsp = start + t1 + t2 + t3;
    }
  }
  printf("%d\n", rsp);
  return 0;
}
