#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
int n;
int a[100000];
void solve(int m, int t) {
  for (int i = 0; i < n; i++) {
    if (i >= m) checkmax(a[i], a[i - m]);
    a[i] += t;
  }
}
int main() {
  int n1, n2, n3, t1, t2, t3;
  cin >> n >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 0; i < n; i++) a[i] = 0;
  solve(n1, t1);
  solve(n2, t2);
  solve(n3, t3);
  int r = 0;
  for (int i = 0; i < n; i++)
    if (a[i] > r) r = a[i];
  printf("%d\n", r);
  return 0;
}
