#include <bits/stdc++.h>
using namespace std;
queue<int> Q1, Q2, Q3;
vector<int> rec;
int max(int a, int b, int c) {
  int ret = 0;
  ret = max(ret, a);
  ret = max(ret, b);
  ret = max(ret, c);
  return ret;
}
int main() {
  int k, n1, n2, n3, t1, t2, t3, T1, T2, T3;
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  for (int i = 1; i <= k; i++) {
    if (n1 > 0)
      T1 = 0;
    else
      T1 = Q1.front() + t1;
    if (n2 > 0)
      T2 = 0;
    else
      T2 = Q2.front() + t2;
    if (n3 > 0)
      T3 = 0;
    else
      T3 = Q3.front() + t3;
    int t = max(T1, T2 - t1, T3 - t2 - t1);
    rec.push_back(t);
    if (n1 > 0)
      n1--;
    else
      Q1.pop();
    if (n2 > 0)
      n2--;
    else
      Q2.pop();
    if (n3 > 0)
      n3--;
    else
      Q3.pop();
    Q1.push(t);
    Q2.push(t + t1);
    Q3.push(t + t1 + t2);
  }
  printf("%d\n", rec[k - 1] + t1 + t2 + t3);
  return 0;
}
