#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  while (cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3) {
    multiset<int> S1, S2, S3;
    for (int i = 0; i < n1; i++) S1.insert(0);
    for (int i = 0; i < n2; i++) S2.insert(0);
    for (int i = 0; i < n3; i++) S3.insert(0);
    int ans = 0;
    for (int i = 0; i < k; i++) {
      multiset<int>::iterator it1, it2, it3;
      it1 = S1.begin();
      it2 = S2.begin();
      it3 = S3.begin();
      int t = max(*it1, max(*it2 - t1, *it3 - t2 - t1));
      S1.erase(it1);
      S2.erase(it2);
      S3.erase(it3);
      S1.insert(t + t1);
      S2.insert(t + t1 + t2);
      S3.insert(t + t1 + t2 + t3);
      ans = t + t1 + t2 + t3;
    }
    cout << ans << endl;
  }
  return 0;
}
