#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
vector<int> a, b, c;
void push(int x, int y, int z) {
  a.push_back(x), b.push_back(y), c.push_back(z);
}
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 0; i < n1; ++i) a.push_back(0);
  for (int i = 0; i < n2; ++i) b.push_back(0);
  for (int i = 0; i < n3; ++i) c.push_back(0);
  int i = 0;
  while (k) {
    if (a[i] <= b[i] && b[i] <= c[i]) {
      if (a[i] + t1 >= b[i] && b[i] + t2 >= c[i])
        push(a[i] + t1, a[i] + t1 + t2, a[i] + t1 + t2 + t3);
      else if (b[i] + t2 >= c[i])
        push(b[i], b[i] + t2, b[i] + t2 + t3);
      else
        push(c[i] - t2, c[i], c[i] + t3);
    } else if (a[i] <= b[i] && b[i] > c[i]) {
      if (a[i] + t1 >= b[i])
        push(a[i] + t1, a[i] + t1 + t2, a[i] + t1 + t2 + t3);
      else
        push(b[i] - t1, b[i] + t2, b[i] + t2 + t3);
    } else
      push(a[i] + t1, a[i] + t1 + t2, a[i] + t1 + t2 + t3);
    cerr << a[i] << " " << b[i] << " " << c[i] << endl;
    i++, k--;
  }
  cout << c[c.size() - 1];
  return 0;
}
