#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s1, s2, s3;
set<pair<int, int> >::iterator it;
int main() {
  int k, n1, n2, n3, t1, t2, t3, ans = 0, p1, p2, p3, i1, i2, i3, m = 0;
  int i;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (i = 0; i < n1; i++) {
    s1.insert(make_pair(0, i));
  }
  for (i = 0; i < n2; i++) {
    s2.insert(make_pair(0, i));
  }
  for (i = 0; i < n3; i++) {
    s3.insert(make_pair(0, i));
  }
  for (i = 0; i < k; i++) {
    it = s1.begin();
    p1 = (*it).first;
    i1 = (*it).second;
    s1.erase(it);
    it = s2.begin();
    p2 = (*it).first;
    i2 = (*it).second;
    s2.erase(it);
    it = s3.begin();
    p3 = (*it).first;
    i3 = (*it).second;
    s3.erase(it);
    m = max(p1 + t1 + t2 + t3, max(p2 + t2 + t3, p3 + t3));
    p1 = m - t2 - t3;
    p2 = m - t3;
    p3 = m;
    s1.insert(make_pair(p1, i1));
    s2.insert(make_pair(p2, i2));
    s3.insert(make_pair(p3, i3));
  }
  cout << m << endl;
  return 0;
}
