#include <bits/stdc++.h>
using namespace std;
int freetime[3][10010];
int num_machine[3];
int time_taken[3];
int num_piece;
int result;
int main() {
  cin >> num_piece;
  cin >> num_machine[0] >> num_machine[1] >> num_machine[2];
  cin >> time_taken[0] >> time_taken[1] >> time_taken[2];
  memset(freetime, 0, sizeof(freetime));
  for (int i = 0; i < num_piece; ++i) {
    int et = 0, best, idbest;
    for (int t = 0; t < 3; ++t) {
      best = freetime[t][0];
      idbest = 0;
      for (int j = 1; j < num_machine[t]; ++j) {
        if (freetime[t][j] < best) {
          best = freetime[t][j];
          idbest = j;
        }
      }
      if (best < et) {
        freetime[t][idbest] = et + time_taken[t];
      } else {
        freetime[t][idbest] += time_taken[t];
      }
      et = freetime[t][idbest];
    }
    result = et;
  }
  cout << result << endl;
  return 0;
}
