#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
;
const double pi = acos(-1.0);
template <class T>
inline T sqr(T a) {
  return a * a;
}
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int pw(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base;
  int tmp = pw(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
multiset<int> S1, S2, S3;
int K, n1, n2, n3, t1, t2, t3, t;
int main() {
  scanf("%d%d%d%d%d%d%d", &K, &n1, &n2, &n3, &t1, &t2, &t3);
  while (K || S1.size() || S2.size() || S3.size()) {
    ++t;
    while (S3.size() && *S3.begin() + t3 <= t) {
      S3.erase(S3.begin());
    }
    while (S2.size() && *S2.begin() + t2 <= t && S3.size() < n3) {
      S3.insert(t);
      S2.erase(S2.begin());
    }
    while (S1.size() && *S1.begin() + t1 <= t && S2.size() < n2) {
      S2.insert(t);
      S1.erase(S1.begin());
    }
    while (S1.size() < n1 && K) {
      K--;
      S1.insert(t);
    }
  }
  printf("%d\n", t - 1);
  return 0;
}
