#include <bits/stdc++.h>
using namespace std;
long long arr[10002];
void solve(int k, int n1, int t1) {
  int tmp = k;
  int pos = 0;
  int cc = 1;
  while (tmp > 0) {
    for (int i = 0; i < min(tmp, n1); i += 1) {
      if (pos >= n1) {
        arr[pos] = max(arr[pos], arr[pos - n1]) + t1;
      } else
        arr[pos] += t1;
      --tmp;
      ++pos;
    }
    ++cc;
  }
}
int main(int argc, char const* argv[]) {
  int k, n1, n2, n3, t1, t2, t3;
  scanf("%d", &k);
  scanf("%d %d %d", &n1, &n2, &n3);
  scanf("%d %d %d", &t1, &t2, &t3);
  solve(k, n1, t1);
  solve(k, n2, t2);
  solve(k, n3, t3);
  cout << *max_element(arr, arr + k) << "\n";
  return 0;
}
