#include <bits/stdc++.h>
using namespace std;
long long k, n[3], t[3];
long long delay[3][1005];
int main() {
  cin >> k;
  for (int i = 0; i < 3; ++i) {
    cin >> n[i];
  }
  long long whole = 0L;
  for (int i = 0; i < 3; ++i) {
    cin >> t[i];
    whole += t[i];
  }
  if (k == 1) {
    cout << whole << endl;
    return 0;
  }
  memset(delay, 0, sizeof(delay));
  long long startTime = 0L;
  for (long long cloth = 1; cloth <= k; ++cloth) {
    long long chooseIdx[3];
    memset(chooseIdx, 0, sizeof(chooseIdx));
    startTime = 0L;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < n[i]; ++j) {
        if (delay[i][j] < delay[i][chooseIdx[i]]) {
          chooseIdx[i] = j;
        }
      }
      long long temp = delay[i][chooseIdx[i]];
      for (int j = 0; j <= i - 1; ++j) {
        temp -= t[j];
      }
      if (temp > startTime) startTime = temp;
    }
    if (cloth == k) break;
    for (int i = 0; i < 3; ++i) {
      delay[i][chooseIdx[i]] = startTime + t[i];
      startTime += t[i];
    }
  }
  cout << startTime + whole << endl;
  return 0;
}
