#include <bits/stdc++.h>
using namespace std;
long k, n1, n2, n3, t1, t2, t3, v1, v2, v3, start;
multiset<long> s1, s2, s3;
multiset<long>::iterator it;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 1; i <= n1; i++) s1.insert(0);
  for (int i = 1; i <= n2; i++) s2.insert(-t1);
  for (int i = 1; i <= n3; i++) s3.insert(-t1 - t2);
  for (int i = 1; i <= k; i++) {
    it = s1.begin();
    v1 = (*it);
    it = s2.begin();
    v2 = (*it);
    it = s3.begin();
    v3 = (*it);
    start = max(v1, max(v2, v3));
    it = s1.begin();
    s1.erase(it);
    it = s2.begin();
    s2.erase(it);
    it = s3.begin();
    s3.erase(it);
    s1.insert(start + t1);
    s2.insert(start + t1 + t2 - t1);
    s3.insert(start + t1 + t2 + t3 - t1 - t2);
  }
  cout << start + t1 + t2 + t3 << endl;
  cin.get();
  cin.get();
  return 0;
}
