#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k, n1, n2, n3, t1, t2, t3, ans = 0;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  multiset<int> S1, S2, S3;
  for (int i = 0; i < n1; i++) S1.insert(0);
  for (int i = 0; i < n2; i++) S2.insert(0);
  for (int i = 0; i < n3; i++) S3.insert(0);
  for (int i = 0; i < k; i++) {
    int now = *S1.begin();
    S1.erase(S1.begin());
    now += t1;
    S1.insert(now);
    now = max(now, *S2.begin());
    S2.erase(S2.begin());
    now += t2;
    S2.insert(now);
    now = max(now, *S3.begin());
    S3.erase(S3.begin());
    now += t3;
    S3.insert(now);
    ans = max(now, ans);
  }
  cout << ans;
  return 0;
}
