#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
int K, N[3], T[3];
priority_queue<int, vector<int>, greater<int> > A[3];
void solve() {
  int f, i, j, k, l, x, y;
  cin >> K >> N[0] >> N[1] >> N[2] >> T[0] >> T[1] >> T[2];
  for (i = 0; i < N[0]; i++) A[0].push(0);
  for (i = 0; i < N[1]; i++) A[1].push(0);
  for (i = 0; i < N[2]; i++) A[2].push(0);
  int ret = 0;
  for (i = 0; i < K; i++) {
    x = max(0, A[0].top());
    x = max(x, A[1].top() - T[0]);
    x = max(x, A[2].top() - T[0] - T[1]);
    ret = max(ret, x + T[0] + T[1] + T[2]);
    A[0].pop();
    A[1].pop();
    A[2].pop();
    A[0].push(x + T[0]);
    A[1].push(x + T[0] + T[1]);
    A[2].push(x + T[0] + T[1] + T[2]);
  }
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  if (argc == 1) ios::sync_with_stdio(false);
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
