#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
long long P = 1e9 + 7;
long long INF = 1e18;
multiset<int> s1, s2, s3;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  int i;
  for (i = 0; i < n1; i++) s1.insert(0);
  for (i = 0; i < n2; i++) s2.insert(0);
  for (i = 0; i < n3; i++) s3.insert(0);
  for (i = 0; i < k; i++) {
    multiset<int>::iterator it1 = s1.begin();
    multiset<int>::iterator it2 = s2.begin();
    multiset<int>::iterator it3 = s3.begin();
    int w1, w2, w3;
    w1 = (*it1);
    w2 = (*it2);
    w3 = (*it3);
    s1.erase(it1);
    s2.erase(it2);
    s3.erase(it3);
    if (w2 <= w1 + t1 && w3 <= w1 + t1 + t2) {
      s1.insert(w1 + t1);
      s2.insert(w1 + t1 + t2);
      s3.insert(w1 + t1 + t2 + t3);
      continue;
    }
    if (w1 <= w2 - t1 && w3 <= w2 + t2) {
      s1.insert(w2);
      s2.insert(w2 + t2);
      s3.insert(w2 + t2 + t3);
      continue;
    }
    if (w1 <= w3 - t2 - t1 && w2 <= w3 - t2) {
      s1.insert(w3 - t2);
      s2.insert(w3);
      s3.insert(w3 + t3);
      continue;
    }
  }
  multiset<int>::iterator it3 = s3.end();
  it3--;
  cout << (*it3);
  return 0;
}
