#include <bits/stdc++.h>
using namespace std;
queue<int> que[3];
int k, n[3], t[3];
int main() {
  cin >> k >> n[0] >> n[1] >> n[2] >> t[0] >> t[1] >> t[2];
  t[1] += t[0];
  t[2] += t[1];
  int cur = 0;
  for (int i = 0; i < (int)3; i++)
    for (int j = 0; j < (int)n[i]; j++) que[i].push(0);
  for (int i = 0; i < (int)k; i++) {
    for (int j = 0; j < (int)3; j++)
      if (cur + ((j) ? t[j - 1] : 0) < que[j].front())
        cur = que[j].front() - ((j) ? t[j - 1] : 0);
    for (int j = 0; j < (int)3; j++) {
      que[j].pop();
      que[j].push(cur + t[j]);
    }
  }
  cout << cur + t[2] << endl;
  return 0;
}
