#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
bool isone(long long, int);
int count(long long);
long long exp(long long, long long, long long);
long long GCD(long long, long long);
set<pair<int, int> > a;
set<pair<int, int> > b;
set<pair<int, int> > c;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  for (int i = 1; i <= n1; i++) a.insert(make_pair(0, i));
  for (int i = 1; i <= n2; i++) b.insert(make_pair(0, i));
  for (int i = 1; i <= n3; i++) c.insert(make_pair(0, i));
  int ans = 0;
  for (int i = 0; i < k; i++) {
    set<pair<int, int> >::iterator it = a.begin();
    a.erase(it);
    pair<int, int> t = *it;
    int end = t.first + t1;
    a.insert(make_pair(end, t.second));
    it = b.begin();
    b.erase(it);
    t = *it;
    if (end >= t.first) {
      end = end + t2;
      b.insert(make_pair(end, t.second));
    } else {
      end = t.first + t2;
      b.insert(make_pair(end, t.second));
    }
    it = c.begin();
    c.erase(it);
    t = *it;
    if (end >= t.first) {
      end = end + t3;
      c.insert(make_pair(end, t.second));
      ans = max(ans, end);
    } else {
      end = t.first + t3;
      c.insert(make_pair(end, t.second));
      ans = max(ans, end);
    }
  }
  printf("%d\n", ans);
  return 0;
}
long long GCD(long long a, long long b) {
  if (!b)
    return a;
  else
    return GCD(b, a % b);
}
long long exp(long long a, long long b, long long c) {
  long long ret = 1LL;
  long long mult = a;
  while (b) {
    if (b & 1) ret = (ret * mult) % c;
    mult = (mult * mult) % c;
    b >>= 1;
  }
  return ret;
}
int count(long long x) {
  int ret = 0;
  while (x) {
    if (x & 1) ret++;
    x >>= 1LL;
  }
  return ret;
}
bool isone(long long x, int pos) { return x & (1 << pos); }
