#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
long long modInv(long long a) { return binpow(a, MOD - 2); }
bool sortcol(const vector<long long>& v1, const vector<long long>& v2) {
  return v1[1] < v2[1];
}
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
int pct(int x) { return __builtin_popcount(x); }
int bits(int x) { return 31 - __builtin_clz(x); }
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
int fstTrue(function<bool(int)> first, int lo, int hi) {
  hi++;
  assert(lo <= hi);
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    first(mid) ? hi = mid : lo = mid + 1;
  }
  return lo;
}
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mxN = 2e5;
int q = 1, k, n1, n2, n3, t1, t2, t3, x, a, b, c;
priority_queue<int, vector<int>, greater<int>> pq1, pq2, pq3;
void solve() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = (0); i < (n3); i++) pq3.push(t3);
  for (int i = (0); i < (n2); i++) pq2.push(t3 + t2);
  for (int i = (0); i < (n1); i++) pq1.push(t3 + t2 + t1);
  for (int i = (0); i < (k); i++) {
    a = pq1.top();
    pq1.pop();
    b = pq2.top();
    pq2.pop();
    c = pq3.top();
    pq3.pop();
    x = max({a, b, c});
    pq1.push(x + t1);
    pq2.push(x + t2);
    pq3.push(x + t3);
  }
  cout << x << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (q--) {
    solve();
  }
}
