#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3, t1, t2, t3;
vector<int> r1, r2, r3;
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  int i1 = 0, i2 = 0, i3 = 0;
  int q1 = k, q2 = 0, q3 = 0;
  int left = k;
  for (int t = 0;; t++) {
    while (i3 < (int)r3.size() && r3[i3] == t) {
      i3++;
      n3++;
      left--;
      if (left == 0) {
        printf("%d\n", t);
        return 0;
      }
    }
    while (q3 > 0 && n3 > 0) {
      r3.push_back(t + t3);
      q3--;
      n3--;
    }
    while (i2 < (int)r2.size() && r2[i2] == t) {
      i2++;
      n2++;
      if (n3 > 0) {
        r3.push_back(t + t3);
        n3--;
      } else {
        q3++;
      }
    }
    while (q2 > 0 && n2 > 0) {
      r2.push_back(t + t2);
      q2--;
      n2--;
    }
    while (i1 < (int)r1.size() && r1[i1] == t) {
      i1++;
      n1++;
      if (n2 > 0) {
        r2.push_back(t + t2);
        n2--;
      } else {
        q2++;
      }
    }
    while (q1 > 0 && n1 > 0) {
      r1.push_back(t + t1);
      q1--;
      n1--;
    }
  }
}
