#include <bits/stdc++.h>
using namespace std;
int n[4];
int t[4];
int a[5];
int k;
struct Node {
  int tm;
  int type;
  int num;
  void init(int a, int b, int c) { tm = a, type = b, num = c; }
  bool operator<(const Node& nd) const {
    if (tm == nd.tm)
      return type < nd.type;
    else
      return tm > nd.tm;
  }
};
priority_queue<Node> pq;
int main() {
  cin >> k >> n[1] >> n[2] >> n[3];
  cin >> t[1] >> t[2] >> t[3];
  a[0] = k;
  Node nd;
  nd.init(t[1], 1, min(k, n[1]));
  a[0] -= min(k, n[1]);
  n[1] -= min(k, n[1]);
  pq.push(nd);
  int res = -1;
  while (a[4] < k) {
    Node nd = pq.top();
    pq.pop();
    a[nd.type] += nd.num;
    n[nd.type] += nd.num;
    int tm = nd.tm;
    res = tm;
    if (a[3]) {
      a[4] += a[3];
      a[3] = 0;
    }
    if (a[2] && n[3]) {
      int tmp = min(a[2], n[3]);
      a[2] -= tmp;
      n[3] -= tmp;
      Node nd;
      nd.init(tm + t[3], 3, tmp);
      pq.push(nd);
    }
    if (a[1] && n[2]) {
      int tmp = min(a[1], n[2]);
      a[1] -= tmp;
      n[2] -= tmp;
      Node nd;
      nd.init(tm + t[2], 2, tmp);
      pq.push(nd);
    }
    if (a[0] && n[1]) {
      int tmp = min(a[0], n[1]);
      a[0] -= tmp;
      n[1] -= tmp;
      Node nd;
      nd.init(tm + t[1], 1, tmp);
      pq.push(nd);
    }
  }
  cout << res << endl;
  return 0;
}
