#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
int k, t[3], n[3];
int res = 0;
multiset<int> second[3];
int main(void) {
  cin >> k >> n[0] >> n[1] >> n[2] >> t[0] >> t[1] >> t[2];
  for (int(i) = 0; (i) < (n[0]); ++(i)) second[0].insert(0);
  for (int(i) = 0; (i) < (n[1]); ++(i)) second[1].insert(0);
  for (int(i) = 0; (i) < (n[2]); ++(i)) second[2].insert(0);
  for (int(i) = 0; (i) < (k); ++(i)) {
    int mx = 0;
    int add = 0;
    for (int(j) = 0; (j) < (3); ++(j)) {
      mx = max(mx, (*second[j].begin()) - add);
      add += t[j];
    }
    for (int(j) = 0; (j) < (3); ++(j)) {
      mx += t[j];
      second[j].erase(second[j].begin());
      second[j].insert(mx);
    }
  }
  cout << (*second[2].rbegin()) << "\n";
  return 0;
}
