#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, x, y, z;
priority_queue<int, vector<int>, greater<int> > pqy, pqz;
vector<int> yz;
int main() {
  cin >> n >> a >> b >> c >> x >> y >> z;
  for (int i = 0; i < b; i++) {
    pqy.push(0);
  }
  for (int i = 0; i < n; i++) {
    int cur = x * (i / a + 1);
    int top = max(pqy.top(), cur);
    pqy.pop();
    pqy.push(top + y);
    yz.push_back(top + y);
  }
  for (int i = 0; i < c; i++) {
    pqz.push(0);
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    int cur = yz[i];
    int top = max(pqz.top(), cur);
    pqz.pop();
    pqz.push(top + z);
    res = max(top + z, res);
  }
  cout << res << '\n';
  return 0;
}
