#include <bits/stdc++.h>
using namespace std;
template <class T>
string tostring(T x) {
  ostringstream out;
  out << x;
  return out.str();
}
long long toint(string s) {
  istringstream in(s);
  long long x;
  in >> x;
  return x;
}
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, -1, 1, -1, 1};
int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};
int wash[1000];
int dry[1000];
int fold[1000];
int getMin(int *arr, int n) {
  int mn = -1;
  for (int i = 0; i < n; i++)
    if (mn == -1 || arr[i] < arr[mn]) mn = i;
  return mn;
}
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  int cur = 0;
  for (int i = 0; i < k; i++) {
    int w = getMin(wash, n1);
    int d = getMin(dry, n2);
    int f = getMin(fold, n3);
    if (wash[w] > cur) {
      cur = wash[w];
    }
    if (dry[d] > cur + t1) {
      cur = dry[d] - t1;
    }
    if (fold[f] > cur + t1 + t2) {
      cur = fold[f] - t1 - t2;
    }
    wash[w] = cur + t1;
    dry[d] = cur + t1 + t2;
    fold[f] = cur + t1 + t2 + t3;
  }
  int res = 0;
  for (int i = 0; i < n3; i++) res = max(res, fold[i]);
  cout << res << endl;
  return 0;
}
