#include <bits/stdc++.h>
using namespace std;
long long LLMAX = 9223372036854775807LL;
const int MOD = 1000000007;
const int maxn = 1111111;
int k, n1, n2, n3, t1, t2, t3;
int t[maxn];
int main() {
  scanf("%d %d", &(k), &(n1));
  scanf("%d %d", &(n2), &(n3));
  scanf("%d %d", &(t1), &(t2));
  scanf("%d", &(t3));
  for (int i = 0; i < k; ++i) {
    if (i >= n1) t[i] = max(t[i], t[i - n1]);
    t[i] += t1;
  }
  for (int i = 0; i < k; ++i) {
    if (i >= n2) t[i] = max(t[i], t[i - n2]);
    t[i] += t2;
  }
  for (int i = 0; i < k; ++i) {
    if (i >= n3) t[i] = max(t[i], t[i - n3]);
    t[i] += t3;
  }
  int ans = 0;
  for (int i = 0; i < k; ++i) ans = max(ans, t[i]);
  printf("%d\n", (ans));
}
