#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const int mod = 1000000007;
const int maxn = 1000005;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  queue<int> q1;
  queue<int> q2;
  queue<int> q3;
  while (n1--) q1.push(0);
  while (n2--) q2.push(0);
  while (n3--) q3.push(0);
  int ans = 0;
  while (k > 0) {
    int x1 = q1.front();
    int x2 = q2.front() - t1;
    int x3 = q3.front() - t1 - t2;
    if (ans >= x1 && ans >= x2 && ans >= x3) {
      q1.pop();
      q1.push(ans + t1);
      q2.pop();
      q2.push(ans + t1 + t2);
      q3.pop();
      q3.push(ans + t1 + t2 + t3);
      k--;
    } else
      ans = max(max(x1, x2), x3);
  }
  ans += t1 + t2 + t3;
  printf("%d\n", ans);
  return 0;
}
