#include <bits/stdc++.h>
using namespace std;
void modify(queue<int> &q, int time, int t) {
  while (q.size() && q.front() + t <= time) q.pop();
}
void upd(queue<int> &q, int time, int n, int &f, int t) {
  if (q.size() == n) modify(q, time, t);
  q.push(time);
  if (q.size() == n) f = q.front() + t;
}
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  queue<int> one, two, three;
  int f1 = 0, f2 = t1, f3 = t1 + t2;
  int b1 = 0, b2 = f2, b3 = f3;
  int mxt = 0;
  for (long int i = 1; i <= k - 1; i++) {
    int time = mxt;
    upd(one, time, n1, f1, t1);
    mxt = max(mxt, f1 - b1);
    upd(two, time + t1, n2, f2, t2);
    mxt = max(mxt, f2 - b2);
    upd(three, time + t1 + t2, n3, f3, t3);
    mxt = max(mxt, f3 - b3);
  }
  cout << mxt + t1 + t2 + t3 << endl;
  return 0;
}
