#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
void solve() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  set<pair<long long, int>> st[3];
  for (int i = 1; i <= 1000; i++) {
    if (i <= n1) {
      st[0].insert({0, i});
    }
    if (i <= n2) {
      st[1].insert({0, i});
    }
    if (i <= n3) {
      st[2].insert({0, i});
    }
  }
  long long ans = 0;
  while (k--) {
    auto beg0 = *st[0].begin();
    auto beg1 = *st[1].begin();
    auto beg2 = *st[2].begin();
    auto last0 = beg0, last1 = beg1, last2 = beg2;
    st[0].erase(beg0);
    st[1].erase(beg1);
    st[2].erase(beg2);
    beg0.first += t1;
    beg1.first = max(beg1.first + t2, beg0.first + t2);
    beg2.first = max(beg2.first + t3, beg1.first + t3);
    ans = max(ans, beg2.first);
    beg1.first = beg2.first - t3;
    beg0.first = beg1.first - t2;
    assert(last0.first <= beg0.first);
    assert(last1.first <= beg1.first);
    assert(last2.first <= beg2.first);
    st[0].insert(beg0);
    st[1].insert(beg1);
    st[2].insert(beg2);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(7);
  int step = 1;
  for (int i = 1; i <= step; i++) {
    solve();
  }
}
