#include <bits/stdc++.h>
using namespace std;
const int K = 10010;
const int N = 1010;
const int inf = (int)1e9;
multiset<int> wash, dry, fold;
int k, n1, n2, n3, t1, t2, t3;
bool ok(int curTime) {
  if (((int)wash.size()) < n1 or curTime >= *wash.begin()) {
    if (((int)dry.size()) < n2 or curTime + t1 >= *dry.begin()) {
      if (((int)fold.size()) < n3 or curTime + t1 + t2 >= *fold.begin()) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  int curTime = 0;
  int ans = 0;
  for (int i = 0; i < (k); ++i) {
    int l = curTime, r = inf;
    while (l < r) {
      int m = (l + r) >> 1;
      if (!ok(m))
        l = m + 1;
      else
        r = m;
    }
    curTime = l;
    if (((int)wash.size()) == n1) {
      wash.erase(wash.begin());
    }
    if (((int)dry.size()) == n2) {
      dry.erase(dry.begin());
    }
    if (((int)fold.size()) == n3) {
      fold.erase(fold.begin());
    }
    wash.insert(curTime + t1);
    dry.insert(curTime + t1 + t2);
    fold.insert(curTime + t1 + t2 + t3);
    ans = max(ans, curTime + t1 + t2 + t3);
  }
  printf("%d\n", ans);
  return 0;
}
