#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> pq1, pq2, pq3;
int main(int argc, char *argv[]) {
  int k, n1, n2, n3, t1, t2, t3;
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  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);
  for (int i = 0; i < (k); i++) {
    long long s1 = -pq1.top(), s2 = -pq2.top(), s3 = -pq3.top();
    pq1.pop();
    pq2.pop();
    pq3.pop();
    long long start = max(s1, max(s2 - t1, s3 - t1 - t2));
    pq1.push(-start - t1);
    pq2.push(-start - t1 - t2);
    pq3.push(-start - t1 - t2 - t3);
    if (i == k - 1) cout << start + t1 + t2 + t3 << endl;
  }
  return 0;
}
