#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, greater<int> > m1, m2, m3;
int k, n1, n2, n3, t1, t2, t3;
int main() {
  int i, m, r;
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  m = (n1 < n2) ? n1 : n2;
  m = (m < n3) ? m : n3;
  for (i = 0; i < n1; ++i) {
    m1.push(0);
  }
  for (i = 0; i < n2; ++i) {
    m2.push(0);
  }
  for (i = 0; i < n3; ++i) {
    m3.push(0);
  }
  while (k--) {
    r = m1.top();
    m = (r > m2.top()) ? r : m2.top();
    m = (m > m3.top()) ? m : m3.top();
    m1.pop();
    m2.pop();
    m3.pop();
    m1.push(t1 + m);
    m2.push(t2 + m);
    m3.push(t3 + m);
  }
  printf("%d\n", m + t1 + t2 + t3);
  return 0;
}
