#include <bits/stdc++.h>
using namespace std;
int ms[3][1000] = {};
int main(int argc, char **argv) {
  int k, n[3], t[3];
  cin >> k;
  for (int i = 0; i < 3; i++) {
    cin >> n[i];
  }
  for (int i = 0; i < 3; i++) {
    cin >> t[i];
  }
  int ct = 1;
  int m[3] = {};
  int w[3] = {};
  w[0] = k;
  while (1) {
    int nextT = 1000000000;
    int nextM = -1;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < n[i]; j++) {
        if (ms[i][j] + t[i] == ct) {
          if (i != 3) {
            w[i + 1]++;
          }
          m[i]--;
          ms[i][j] = 0;
        }
      }
      for (int j = 0; j < n[i]; j++) {
        if ((w[i] == 0) || (m[i] == n[i])) {
          break;
        }
        if (!ms[i][j]) {
          m[i]++;
          w[i]--;
          ms[i][j] = ct;
        }
      }
      for (int j = 0; j < n[i]; j++) {
        if (ms[i][j]) {
          nextT = min(nextT, ms[i][j] + t[i]);
          nextM = i;
        }
      }
    }
    if (nextM != -1) {
      ct = nextT;
    } else {
      break;
    }
  }
  cout << ct - 1 << endl;
  return 0;
}
