#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int N = 1010;
int k;
int cnt[3];
int fasdgasdfjib[3];
int tfree[3][N];
set<pair<int, int> > q[3];
int ans;
int main() {
  cin >> k;
  for (int i = 0; i < 3; ++i) cin >> cnt[i];
  for (int i = 0; i < 3; ++i) cin >> fasdgasdfjib[i];
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < cnt[i]; ++j) q[i].insert(make_pair(0, j));
  for (int i = 0; i < k; ++i) {
    int s = q[0].begin()->first;
    s = max(s, q[1].begin()->first - fasdgasdfjib[0]);
    s = max(s, q[2].begin()->first - fasdgasdfjib[0] - fasdgasdfjib[1]);
    ans = max(ans, s + fasdgasdfjib[0] + fasdgasdfjib[1] + fasdgasdfjib[2]);
    for (int j = 0; j < 3; ++j) {
      int z = q[j].begin()->second;
      q[j].erase(q[j].begin());
      tfree[j][z] = s;
      for (int l = 0; l <= j; ++l) tfree[j][z] += fasdgasdfjib[l];
      q[j].insert(make_pair(tfree[j][z], z));
    }
  }
  cout << ans << endl;
  return 0;
}
