#include <bits/stdc++.h>
using namespace std;
namespace p452DWasherDryerFolder {
void solve(int test_num) {
  const int INF = 1000000000;
  int K, num[3], take[3];
  int res = 0;
  cin >> K >> num[0] >> num[1] >> num[2] >> take[0] >> take[1] >> take[2];
  int have[3] = {0, num[1], num[2]};
  priority_queue<int, vector<int>, greater<int> > q[3];
  for (int i = 0; i < 3; i++) q[i].push(INF);
  for (int i = 0; i < min(K, num[0]); i++) {
    q[0].push(take[0]);
    K--;
  }
  while (true) {
    if (q[2].top() <= min(q[0].top(), q[1].top())) {
      if (q[2].top() == INF) break;
      res = q[2].top();
      q[2].pop();
      have[2]++;
    } else if (q[1].top() <= q[0].top()) {
      const int t_dry = q[1].top();
      q[1].pop();
      if (have[2]) {
        have[2]--;
        q[2].push(t_dry + take[2]);
        have[1]++;
      } else {
        q[1].push(q[2].top());
      }
    } else {
      const int t_wash = q[0].top();
      q[0].pop();
      if (have[1]) {
        have[1]--;
        q[1].push(t_wash + take[1]);
        if (K > 0) {
          K--;
          q[0].push(t_wash + take[0]);
        }
      } else {
        q[0].push(q[1].top());
      }
    }
  }
  cout << res << endl;
}
void solve() { solve(1); }
}  // namespace p452DWasherDryerFolder
int main() {
  p452DWasherDryerFolder::solve();
  return 0;
}
