#include <bits/stdc++.h>
using namespace std;
class cmp {
 public:
  bool operator()(const int &a, const int &b) { return a > b; }
};
priority_queue<int, vector<int>, cmp> pq[10];
int k;
int n[10], t[10];
int sol;
void update(int u, int v, int time) {
  while (!pq[u].empty() && pq[v].size() < n[v] && pq[u].top() <= time) {
    pq[u].pop();
    pq[v].push(time + t[v]);
    sol = max(sol, time + t[v]);
  }
}
int getNextTime(int time) {
  int nextTime = 1000000000;
  for (int i = 0; i <= 3; i++) {
    if (!pq[i].empty() && pq[i].top() > time) {
      nextTime = min(nextTime, pq[i].top());
    }
  }
  return nextTime;
}
int main() {
  sol = 0;
  memset(t, 0, sizeof(t));
  scanf("%d%d%d%d%d%d%d", &k, &n[1], &n[2], &n[3], &t[1], &t[2], &t[3]);
  n[0] = n[4] = k;
  for (int i = 0; i < k; i++) {
    pq[0].push(0);
  }
  int time = 0;
  while (pq[4].size() < k) {
    for (int i = 4; i > 0; i--) {
      update(i - 1, i, time);
    }
    time = getNextTime(time);
  }
  printf("%d\n", sol);
  return 0;
}
