#include <bits/stdc++.h>
using namespace std;
int n;
int m[4];
int t[4];
int s[4];
pair<int, int> b[4];
set<pair<int, int> > a[4];
int ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("%d", &m[i]);
    for (int j = 0; j < m[i]; j++) a[i].insert(make_pair(0, j));
  }
  for (int i = 0; i < 3; i++) scanf("%d", &t[i]);
  for (int i = 1; i < 4; i++) s[i] = s[i - 1] + t[i - 1];
  while (n--) {
    int first = 0;
    for (int i = 0; i < 3; i++) {
      b[i] = *a[i].begin();
      a[i].erase(a[i].begin());
      first = max(first, b[i].first - s[i]);
    }
    ans = first + s[3];
    for (int i = 0; i < 3; i++)
      a[i].insert(make_pair(first + s[i + 1], b[i].second));
  }
  printf("%d\n", ans);
  return 0;
}
