#include <bits/stdc++.h>
using namespace std;
class Compare {
 public:
  bool operator()(pair<long long, long long> a, pair<long long, long long> b) {
    return (a.first + a.second) > (b.first + b.second);
  }
};
int main() {
  long long test, x, n, m, k, w, d, f, y;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >, Compare>
      pqw;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >, Compare>
      pqd;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >, Compare>
      pqf;
  scanf("%lld%lld%lld%lld%lld%lld%lld", &x, &n, &m, &k, &w, &d, &f);
  for (long long i = 0; i < n; i++) {
    pqw.push(make_pair(0, w));
  }
  for (long long i = 0; i < m; i++) {
    pqd.push(make_pair(0, d));
  }
  for (long long i = 0; i < k; i++) {
    pqf.push(make_pair(0, f));
  }
  long long ans = 0;
  for (long long i = 0; i < x; i++) {
    pair<long long, long long> cur = pqw.top();
    pqw.pop();
    pqw.push(make_pair(cur.first + cur.second, cur.second));
    pair<long long, long long> curd = pqd.top();
    pqd.pop();
    curd.first = max(cur.first + cur.second, curd.first) + d;
    pqd.push(curd);
    pair<long long, long long> curf = pqf.top();
    pqf.pop();
    curf.first = max(curd.first, curf.first) + f;
    pqf.push(curf);
    ans = curf.first;
  }
  cout << ans;
  return 0;
}
