#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  for (int i = 0; i < n1; ++i) pq.push(pair<int, int>(0, 1));
  for (int i = 0; i < n2; ++i) pq.push(pair<int, int>(0, 2));
  for (int i = 0; i < n3; ++i) pq.push(pair<int, int>(0, 3));
  int out = 0, c[4] = {0};
  while (k) {
    pair<int, int> cur = pq.top();
    pq.pop();
    ++c[cur.second];
    if (c[1] && c[2] && c[3]) {
      k--;
      out = cur.first + t1 + t2 + t3;
      c[1]--;
      c[2]--;
      c[3]--;
      pq.push(pair<int, int>(cur.first + t1, 1));
      pq.push(pair<int, int>(cur.first + t2, 2));
      pq.push(pair<int, int>(cur.first + t3, 3));
    }
  }
  cout << out;
}
