#include <bits/stdc++.h>
using namespace std;
long long r1[1234] = {}, r2[1234] = {}, r3[1234] = {};
int main() {
  long long k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  long long w1 = 0, w2 = 0, w3 = 0;
  long long otvet = 0;
  for (int i = 0; i < k; i++) {
    long long p1 = max(r1[w1], r2[w2] - t1);
    p1 = max(p1, r3[w3] - t1 - t2);
    otvet = max(otvet, p1 + t1 + t2 + t3);
    r1[w1] = p1 + t1;
    r2[w2] = p1 + t1 + t2;
    r3[w3] = p1 + t1 + t2 + t3;
    w1 = (w1 + 1) % n1;
    w2 = (w2 + 1) % n2;
    w3 = (w3 + 1) % n3;
  }
  cout << otvet;
}
