#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7f7f7f7f;
int k, n1, n2, n3, t1, t2, t3;
int w1, w2, w3;
priority_queue<int, vector<int>, greater<int>> q1, q2, q3;
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  w1 = k;
  q1.push(INF), q2.push(INF), q3.push(INF);
  int ans = 0;
  while (w1 || w2 || w3 || q1.size() > 1 || q2.size() > 1 || q3.size() > 1) {
    ans = min(min(q1.top(), q2.top()), q3.top());
    if (ans == INF) ans = 0;
    while (q1.top() <= ans) {
      w2++;
      q1.pop();
    }
    while (q2.top() <= ans) {
      w3++;
      q2.pop();
    }
    while (q3.top() <= ans) {
      q3.pop();
    }
    while (w1 && q1.size() <= n1) {
      w1--;
      q1.push(ans + t1);
    }
    while (w2 && q2.size() <= n2) {
      w2--;
      q2.push(ans + t2);
    }
    while (w3 && q3.size() <= n3) {
      w3--;
      q3.push(ans + t3);
    }
  }
  cout << ans;
}
