#include <bits/stdc++.h>
const long long base = 1000000000 + 7;
using namespace std;
priority_queue<long long> q[3];
long long k;
long long t[3], n[3], u[3];
long long last = 0;
void solve() {
  cin >> k;
  for (int i = 0; i < 3; i++) cin >> n[i];
  for (int i = 0; i < 3; i++) cin >> t[i];
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n[i]; j++) q[i].push(0);
  long long tim = 0;
  while (k--) {
    for (int i = 0; i < 3; i++) u[i] = -q[i].top();
    for (int i = 0; i < 3; i++) q[i].pop();
    while (true) {
      if (tim >= u[0] && tim + t[0] >= u[1] && tim + t[0] + t[1] >= u[2]) break;
      tim++;
    }
    last = tim;
    q[0].push(-(tim + t[0]));
    q[1].push(-(tim + t[0] + t[1]));
    q[2].push(-(tim + t[0] + t[1] + t[2]));
  }
  cout << last + t[0] + t[1] + t[2];
}
int main() {
  ios_base ::sync_with_stdio(false);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
