#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double eps = 1e-7;
const int maxn = 1010;
const long long mod = 1000000007;
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 = 0; i < n1; ++i) q1.push(0);
  for (int i = 0; i < n2; ++i) q2.push(0);
  for (int i = 0; i < n3; ++i) q3.push(0);
  int res = 0;
  while (k--) {
    int a1 = -q1.top();
    q1.pop();
    int a2 = -q2.top();
    q2.pop();
    int a3 = -q3.top();
    q3.pop();
    if (a1 + t1 < a2) a1 = a2 - t1;
    if (a1 + t1 > a2) a2 = a1 + t1;
    if (a2 + t2 < a3) a2 = a3 - t2;
    if (a2 + t2 > a3) a3 = a2 + t2;
    if (a1 + t1 < a2) a1 = a2 - t1;
    if (a1 + t1 > a2) a2 = a1 + t1;
    q1.push(-(a1 + t1));
    q2.push(-(a2 + t2));
    q3.push(-(a3 + t3));
    res = a3 + t3;
  }
  cout << res;
  return 0;
}
