#include <bits/stdc++.h>
using namespace std;
int k;
int n[4], t[4];
class cmp {
 public:
  bool operator()(int &t1, int &t2) { return t1 > t2; };
};
void solve() {
  int i, j, ans, time1, time2, time3, cur;
  priority_queue<int, vector<int>, cmp> pq[4];
  ans = 0;
  for (i = 1; i <= n[1]; i++) pq[1].push(0);
  for (i = 1; i <= n[2]; i++) pq[2].push(0);
  for (i = 1; i <= n[3]; i++) pq[3].push(0);
  for (i = 0; i < k; i++) {
    time1 = pq[1].top();
    pq[1].pop();
    time2 = pq[2].top();
    pq[2].pop();
    time3 = pq[3].top();
    pq[3].pop();
    cur = max(time1, max(time2 - t[1], time3 - t[2] - t[1]));
    ans = max(ans, cur + t[1] + t[2] + t[3]);
    pq[1].push(cur + t[1]);
    pq[2].push(cur + t[1] + t[2]);
    pq[3].push(cur + t[1] + t[2] + t[3]);
  }
  printf("%d\n", ans);
}
void input() {
  scanf("%d %d %d %d %d %d %d", &k, &n[1], &n[2], &n[3], &t[1], &t[2], &t[3]);
  solve();
}
int main() {
  input();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
