#include <bits/stdc++.h>
using namespace std;
int n, n1, n2, n3, t1, t2, t3;
priority_queue<int> q1, q2, q3;
int main() {
  int i, j, k, r;
  int a1, a2, a3, b1, b2, b3;
  scanf("%d %d %d %d %d %d %d", &n, &n1, &n2, &n3, &t1, &t2, &t3);
  for (i = 0; i < n1; i++) q1.push(0);
  for (i = 0; i < n2; i++) q2.push(0);
  for (i = 0; i < n3; i++) q3.push(0);
  for (i = 0; i < n; i++) {
    b1 = -1 * q1.top();
    q1.pop();
    b2 = -1 * q2.top();
    q2.pop();
    b3 = -1 * q3.top();
    q3.pop();
    b2 = max(b1 + t1, b2);
    b3 = max(b2 + t2, b3);
    r = b3 + t3;
    a3 = r;
    a2 = a3 - t3;
    a1 = a2 - t2;
    q1.push(-1 * a1);
    q2.push(-1 * a2);
    q3.push(-1 * a3);
  }
  printf("%d\n", r);
  return 0;
}
