#include <bits/stdc++.h>
using namespace std;
int main() {
  multiset<pair<int, int> > data;
  int wc = 0, wa = 0, wb = 0;
  int k, a, b, c, ta, tb, tc, da = 0, db = 0, dc = 0, t = 0;
  cin >> k >> a >> b >> c >> ta >> tb >> tc;
  pair<int, int> x;
  int y;
  while (da != a && da != k) {
    data.insert(make_pair(ta, 1));
    ++da;
  }
  wa = k - da;
  while (!data.empty()) {
    x = *data.begin();
    t = max(t, x.first);
    data.erase(data.begin());
    if (x.second == 3) {
      --dc;
      if (wc) {
        --wc;
        data.insert(make_pair(x.first + tc, 3));
        ++dc;
      }
    } else if (x.second == 2) {
      --db;
      if (wc || dc == c)
        ++wc;
      else {
        data.insert(make_pair(x.first + tc, 3));
        ++dc;
      }
      if (wb) {
        --wb;
        data.insert(make_pair(x.first + tb, 2));
        ++db;
      }
    } else {
      --da;
      if (wb || db == b)
        ++wb;
      else {
        ++db;
        data.insert(make_pair(x.first + tb, 2));
      }
      if (wa) {
        --wa;
        ++da;
        data.insert(make_pair(x.first + ta, 1));
      }
    }
  }
  cout << t;
}
