#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
vector<int> pass(vector<int> v, int n, int t) {
  sort(v.begin(), v.end());
  vector<int> ret;
  multiset<int> fre;
  for (int i = 0; i < n; ++i) fre.insert(0);
  for (const int elem : v) {
    int nextfree = *fre.begin();
    fre.erase(fre.begin());
    int done = max(nextfree, elem) + t;
    ret.push_back(done);
    fre.insert(done);
  }
  return ret;
}
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  vector<int> elements(k, 0);
  elements = pass(elements, n1, t1);
  elements = pass(elements, n2, t2);
  elements = pass(elements, n3, t3);
  cout << *max_element(elements.begin(), elements.end()) << endl;
  return 0;
}
