#include <bits/stdc++.h>
using namespace std;
const int inf = -10000000;
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  scanf("%d %d %d %d %d %d %d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  priority_queue<int, vector<int>, greater<int> > q1, q2, q3;
  int Time1 = 0, Time2 = 0, Time3 = 0;
  int ans = 0;
  while (k || !q1.empty() || !q2.empty() || !q3.empty()) {
    int pos = -1, Time = 2000000000;
    if (k && q1.size() < n1) {
      pos = 0;
      Time = Time1;
    }
    if (q1.size() > 0 && q2.size() < n2) {
      if (Time > max(q1.top() + t1, Time2)) {
        pos = 1;
        Time = max(q1.top() + t1, Time2);
      }
    }
    if (q2.size() > 0 && q3.size() < n3) {
      if (Time > max(q2.top() + t2, Time3)) {
        pos = 2;
        Time = max(q2.top() + t2, Time3);
      }
    }
    if (q3.size() > 0) {
      if (Time > q3.top() + t3) {
        pos = 3;
        Time = q3.top() + t3;
      }
    }
    if (pos == 0) {
      q1.push(Time);
      --k;
    } else if (pos == 1) {
      q2.push(Time);
      q1.pop();
      Time1 = Time;
    } else if (pos == 2) {
      q3.push(Time);
      q2.pop();
      Time2 = Time;
    } else {
      q3.pop();
      Time3 = Time;
      ans = Time;
    }
  }
  printf("%d\n", ans);
  return 0;
}
