#include <bits/stdc++.h>
using namespace std;
const int MAX = 5e5;
const int mod = 1e9 + 7;
long long arr[MAX], cum[MAX], ans[MAX];
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  priority_queue<int, vector<int>, greater<int>> pq1, pq2, pq3;
  for (int i = 0; i < n1; i++) pq1.push(0);
  for (int i = 0; i < n2; i++) pq2.push(0);
  for (int i = 0; i < n3; i++) pq3.push(0);
  int ans = 0;
  while (k) {
    k--;
    int one = pq1.top();
    one += t1;
    int two = pq2.top();
    if (one < two) {
      one += two - one;
    }
    two = one + t2;
    int three = pq3.top();
    if (two < three) {
      int x = three - two;
      two += x;
      one += x;
    }
    three = two + t3;
    ans = three;
    pq1.pop();
    pq2.pop();
    pq3.pop();
    pq1.push(one);
    pq2.push(two);
    pq3.push(three);
  }
  printf("%d\n", ans);
  return 0;
}
