#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
priority_queue<int, vector<int>, greater<int> > q1, q2, q3;
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  int ret = 0;
  for (int i = 1; i <= k; i++) {
    int T = 0;
    if (q1.size() == n1) {
      T = q1.top();
      q1.pop();
    }
    q1.push(T += t1);
    if (q2.size() == n2) {
      T = max(T, q2.top());
      q2.pop();
    }
    q2.push(T += t2);
    if (q3.size() == n3) {
      T = max(T, q3.top());
      q3.pop();
    }
    q3.push(T += t3);
    ret = T;
  }
  cout << ret;
  return 0;
}
