#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const int N = 100100;
int W[N], D[N], F[N];
int n1, n2, n3, t1, t2, t3, k;
int remain0, remain1, remain2, ans;
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 1; i <= k; i++) {
    int a = W[i % n1] + t1 + t2 + t3;
    int b = D[i % n2] + t2 + t3;
    int c = F[i % n3] + t3;
    int d = max(a, max(b, c));
    W[i % n1] = d - t2 - t3;
    D[i % n2] = d - t3;
    F[i % n3] = d;
    ans = d;
  }
  cout << ans << endl;
}
