#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const double EPS = 1e-12;
const int maxt = 31000000;
int main() {
  ios_base::sync_with_stdio(0);
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  priority_queue<pair<int, pair<int, int> > > pq;
  pq.push(make_pair(0, make_pair(1, 0)));
  int t = 0;
  while (k) {
    pair<int, int> cur = pq.top().second;
    t = -pq.top().first;
    pq.pop();
    if (cur.first == 1)
      n1 += cur.second;
    else if (cur.first == 2)
      n2 += cur.second;
    else
      n3 += cur.second;
    int ile = min(min(n1, k), min(n2, n3));
    if (ile == 0) continue;
    k -= ile;
    n1 -= ile;
    n2 -= ile;
    n3 -= ile;
    pq.push(make_pair(-t - t1, make_pair(1, ile)));
    pq.push(make_pair(-t - t2, make_pair(2, ile)));
    pq.push(make_pair(-t - t3, make_pair(3, ile)));
  }
  cout << t + t1 + t2 + t3 << "\n";
}
