#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
vector<int> v1, v2, v3;
int main() {
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  int m = 0, x = 0;
  for (int i = 0; i < k; i++) {
    x = 0;
    while (v1.size() && v1[0] + t1 <= m + x) {
      v1.erase(v1.begin());
    }
    if (v1.size() == n1) {
      x += max(0, v1[0] + t1 - m);
      v1.erase(v1.begin());
    }
    while (v2.size() && v2[0] + t2 <= m + x + t1) v2.erase(v2.begin());
    if (v2.size() == n2) {
      x += max(v2[0] + t2 - m - x - t1, 0);
      v2.erase(v2.begin());
    }
    while (v3.size() && v3[0] + t3 <= m + x + t1 + t2) v3.erase(v3.begin());
    if (v3.size() == n3) {
      x += max(0, v3[0] + t3 - m - x - t1 - t2);
      v3.erase(v3.begin());
    }
    v1.push_back(m + x);
    v2.push_back(m + x + t1);
    v3.push_back(m + x + t1 + t2);
    m += x;
  }
  printf("%d\n", m + t1 + t2 + t3);
  return 0;
}
