#include <bits/stdc++.h>
using namespace std;
priority_queue<int> q1, q2, q3;
int main() {
  int n, m, t1, t2, t3, i1, i2, i3;
  int s;
  scanf("%d", &n);
  scanf("%d", &m);
  while (m--) q1.push(0);
  scanf("%d", &m);
  while (m--) q2.push(0);
  scanf("%d", &m);
  while (m--) q3.push(0);
  scanf("%d%d%d", &t1, &t2, &t3);
  int ans = 0;
  while (n--) {
    i1 = -q1.top();
    i2 = -q2.top();
    i3 = -q3.top();
    q1.pop();
    q2.pop();
    q3.pop();
    s = max(i1, max(i2 - t1, i3 - t1 - t2));
    ans = s + t1 + t2 + t3;
    q1.push(-(s + t1));
    q2.push(-(s + t1 + t2));
    q3.push(-(s + t1 + t2 + t3));
  }
  printf("%d\n", ans);
  return 0;
}
