#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;
  priority_queue<int> q1, q2, q3;
  for (int i = 1; i <= n1; i++) {
    q1.push(0);
  }
  for (int i = 1; i <= n2; i++) {
    q2.push(0);
  }
  for (int i = 1; i <= n3; i++) {
    q3.push(0);
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    int t = -q1.top();
    q1.pop();
    t += t1;
    q1.push(-t);
    int tx = -q2.top();
    q2.pop();
    t = max(t, tx);
    t += t2;
    q2.push(-t);
    tx = -q3.top();
    q3.pop();
    t = max(t, tx);
    t += t3;
    q3.push(-t);
    ans = t;
  }
  cout << ans;
}
