#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(const T &a) {
  return a * a;
}
int x, k, timer, n[3], t[3], y[3], head[3], tail[3];
pair<int, int> z[3][100000];
int main() {
  scanf("%d%d%d%d%d%d%d", &k, &n[0], &n[1], &n[2], &t[0], &t[1], &t[2]);
  while (1) {
    timer++;
    if (timer >= t[0] + t[1] + t[2]) {
      for (int i = 0; i < (int)3; i++)
        if (z[i][tail[i]].first == timer)
          y[i] -= z[i][tail[i]].second, tail[i]++;
      x = min(n[2] - y[2], min(n[1] - y[1], n[0] - y[0]));
      if (x) {
        k -= x;
        y[2] += x, y[1] += x, y[0] += x;
        z[0][head[0]++] = make_pair(timer + t[0], x);
        z[1][head[1]++] = make_pair(timer + t[1], x);
        z[2][head[2]++] = make_pair(timer + t[2], x);
      }
      if (k <= 0) {
        printf("%d\n", timer);
        return 0;
      }
    }
  }
}
