#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  set<pair<int, int> > a;
  for (int i = 0; i < n1; i++) a.insert(make_pair(0, i));
  set<pair<int, int> > b;
  for (int i = 0; i < n2; i++) b.insert(make_pair(0, i));
  set<pair<int, int> > c;
  for (int i = 0; i < n3; i++) c.insert(make_pair(0, i));
  for (int t = 0; k > 0; t++) {
    bool ok = true;
    while (ok) {
      pair<int, int> x = *a.begin();
      pair<int, int> y = *b.begin();
      pair<int, int> z = *c.begin();
      if (x.first <= t && y.first <= t + t1 && z.first <= t + t1 + t2) {
        k--;
        a.erase(a.begin());
        a.insert(make_pair(t + t1, x.second));
        b.erase(b.begin());
        b.insert(make_pair(t + t1 + t2, y.second));
        c.erase(c.begin());
        c.insert(make_pair(t + t1 + t2 + t3, z.second));
      } else
        ok = false;
    }
  }
  int ans = 0;
  for (auto i = c.begin(); i != c.end(); i++) ans = max(ans, i->first);
  cout << ans << endl;
  return 0;
}
