#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  multiset<int> A, B, C;
  for (int i = 0; i < n1; ++i) A.insert(0);
  for (int i = 0; i < n2; ++i) B.insert(0);
  for (int i = 0; i < n3; ++i) C.insert(0);
  for (int i = 0; i < k; ++i) {
    int a = *A.begin();
    int b = *B.begin();
    int c = *C.begin();
    int t = max(a, max(b - t1, c - t1 - t2));
    A.erase(A.begin());
    A.insert(t + t1);
    B.erase(B.begin());
    B.insert(t + t1 + t2);
    C.erase(C.begin());
    C.insert(t + t1 + t2 + t3);
  }
  int ret = *max_element(C.begin(), C.end());
  cout << ret;
  return 0;
}
