#include <bits/stdc++.h>
using namespace std;
deque<int> m1, m2, m3;
int n1, n2, n3, t1, t2, t3, w1, w2, w3;
int main() {
  ios::sync_with_stdio(false);
  cin >> w1 >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 0; true; ++i) {
    if (!(int)(m1).size() && !(int)(m2).size() && !(int)(m3).size() && !w1 &&
        !w2 && !w3) {
      cout << i - 1 << endl;
      return 0;
    }
    while ((int)(m1).size() && m1[0] <= i) m1.pop_front(), ++w2;
    while ((int)(m2).size() && m2[0] <= i) m2.pop_front(), ++w3;
    while ((int)(m3).size() && m3[0] <= i) m3.pop_front();
    while (w1 && (int)(m1).size() < n1) m1.push_back(i + t1), --w1;
    while (w2 && (int)(m2).size() < n2) m2.push_back(i + t2), --w2;
    while (w3 && (int)(m3).size() < n3) m3.push_back(i + t3), --w3;
  }
  return 0;
}
