#include <bits/stdc++.h>
using namespace std;
const int MX = int(1e3) + 10;
int k, n1, n2, n3, t1, t2, t3;
int w1[MX], w2[MX], w3[MX];
int main() {
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  int ans;
  for (int i = 0; i < k; i++) {
    ans = 0;
    ans = max(ans, w1[i % n1]) + t1;
    ans = max(ans, w2[i % n2]) + t2;
    ans = max(ans, w3[i % n3]) + t3;
    w3[i % n3] = ans;
    w2[i % n2] = ans - t3;
    w1[i % n1] = ans - t3 - t2;
  }
  cout << ans << endl;
}
