#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int f[N];
queue<int> a1, a2, a3;
int main() {
  int k, n1, n2, n3, t1, t2, t3, t = 0, s = 0, i, j;
  while (scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3) != EOF) {
    t = 0, s = 0;
    while (!a1.empty()) a1.pop();
    while (!a2.empty()) a2.pop();
    while (!a3.empty()) a3.pop();
    for (i = 0; i < k; i++) {
      while (true) {
        while (!a1.empty() && a1.front() + t1 <= t) a1.pop();
        while (!a2.empty() && a2.front() + t2 <= t) a2.pop();
        while (!a3.empty() && a3.front() + t3 <= t) a3.pop();
        if (a1.size() < n1 && a2.size() < n2 && a3.size() < n3) {
          a1.push(t);
          a2.push(t);
          a3.push(t);
          s = t + t1 + t2 + t3;
          break;
        }
        int nt = t + 1;
        if (a1.size() == n1) nt = max(nt, a1.front() + t1);
        if (a2.size() == n2) nt = max(nt, a2.front() + t2);
        if (a3.size() == n3) nt = max(nt, a3.front() + t3);
        t = nt;
      }
    }
  }
  printf("%d\n", s);
}
