#include <bits/stdc++.h>
using namespace std;
template <typename T>
string toString(T t) {
  stringstream ss;
  ss << t;
  return ss.str();
}
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = (1LL << 29);
int t[10000];
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  int lo = 0;
  for (int i = lo, q = 0; q < k;) {
    int k1 = q - (upper_bound(t, t + q, i - t1) - t);
    int k2 = q - (upper_bound(t, t + q, i - t2) - t);
    int k3 = q - (upper_bound(t, t + q, i - t3) - t);
    if (k1 < n1 && k2 < n2 && k3 < n3)
      t[q++] = i;
    else
      i++;
  }
  cout << t[k - 1] + t1 + t2 + t3 << endl;
  return 0;
}
