#include <bits/stdc++.h>
using namespace std;
const int INF = 0X3F3F3F3F;
const double PI = acos(-1.0);
const double EPS = 1e-11;
const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
inline int sgn(double x) { return x < -EPS ? -1 : x > EPS ? 1 : 0; }
template <class T>
inline T sqr(const T& x) {
  return x * x;
}
template <class T>
inline int toint(const T& x) {
  stringstream ss;
  ss << x;
  int r;
  ss >> r;
  return r;
}
template <class T>
inline int todouble(const T& x) {
  stringstream ss;
  ss << x;
  double r;
  ss >> r;
  return r;
}
template <class T>
inline string tostr(const T& x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
inline string tolower(string s) {
  for (int i = 0; i < (int)(s.size()); ++i) s[i] = tolower(s[i]);
  return s;
}
inline string toupper(string s) {
  for (int i = 0; i < (int)(s.size()); ++i) s[i] = toupper(s[i]);
  return s;
}
template <class T>
vector<T> split(string s, char c = ' ') {
  stringstream ss(s);
  vector<T> res;
  T t;
  while (ss >> t) {
    res.push_back(t);
    if (ss.peek() == c) ss.ignore();
  }
  return res;
}
template <class T>
vector<T> stov(string s) {
  vector<T> vi;
  stringstream ss(s);
  T v;
  while (ss >> v) vi.push_back(v);
  return vi;
}
template <class T>
string vtos(const vector<T>& vi) {
  stringstream ss;
  for (int i = 0; i < (int)(vi.size()); ++i) {
    if (i > 0) ss << ' ';
    ss << vi[i];
  }
  return ss.str();
}
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline vector<pair<T, int> > factorize(T n) {
  vector<pair<T, int> > R;
  for (T i = 2; n > 1;) {
    if (n % i == 0) {
      int C = 0;
      while (n % i == 0) C++, n /= i;
      R.push_back(make_pair(i, C));
    }
    i++;
    if (i > n / i) i = n;
  }
  if (n > 1) R.push_back(make_pair(n, 1));
  return R;
}
template <class T>
inline bool isprime(T n) {
  if (n < 2) return false;
  for (T i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
template <class T>
inline T phi(T n) {
  vector<pair<T, int> > R = factorize(n);
  T r = n;
  for (int i = 0; i < (int)(R.size()); ++i)
    r = r / R[i].first * (R[i].first - 1);
  return r;
}
int main() {
  int k, n1, n2, n3, t1, t2, t3, last = 0;
  scanf("%d %d %d %d %d %d %d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  queue<int> q1, q2, q3;
  for (int i = 0; i < k; ++i) {
    bool flag = true;
    if (n1 > 0 && n2 > 0 && n3 > 0) {
      q1.push(last + t1);
      q2.push(last + t1 + t2);
      q3.push(last + t1 + t2 + t3);
      --n1, --n2, --n3;
      continue;
    }
    if (n1 == 0) {
      int st = q1.front();
      if ((n2 > 0 || st + t1 >= q2.front()) &&
          (n3 > 0 || st + t1 + t2 >= q3.front())) {
        while (!q1.empty() && q1.front() <= st) {
          q1.pop();
          ++n1;
        }
        while (!q2.empty() && q2.front() <= st + t1) {
          q2.pop();
          ++n2;
        }
        while (!q3.empty() && q3.front() <= st + t1 + t2) {
          q3.pop();
          ++n3;
        }
        q1.push(st + t1);
        q2.push(st + t1 + t2);
        q3.push(st + t1 + t2 + t3);
        --n1, --n2, --n3;
        last = st;
        continue;
      }
    }
    if (n2 == 0) {
      int st = q2.front() - t1;
      if ((n1 > 0 || st >= q1.front()) &&
          (n3 > 0 || st + t1 + t2 >= q3.front())) {
        while (!q1.empty() && q1.front() <= st) {
          q1.pop();
          ++n1;
        }
        while (!q2.empty() && q2.front() <= st + t1) {
          q2.pop();
          ++n2;
        }
        while (!q3.empty() && q3.front() <= st + t1 + t2) {
          q3.pop();
          ++n3;
        }
        q1.push(st + t1);
        q2.push(st + t1 + t2);
        q3.push(st + t1 + t2 + t3);
        --n1, --n2, --n3;
        last = st;
        continue;
      }
    }
    if (n3 == 0) {
      int st = q3.front() - t1 - t2;
      if ((n1 > 0 || st >= q1.front()) && (n2 > 0 || st + t1 >= q2.front())) {
        while (!q1.empty() && q1.front() <= st) {
          q1.pop();
          ++n1;
        }
        while (!q2.empty() && q2.front() <= st + t1) {
          q2.pop();
          ++n2;
        }
        while (!q3.empty() && q3.front() <= st + t1 + t2) {
          q3.pop();
          ++n3;
        }
        q1.push(st + t1);
        q2.push(st + t1 + t2);
        q3.push(st + t1 + t2 + t3);
        --n1, --n2, --n3;
        last = st;
        continue;
      }
    }
  }
  cout << q3.back() << endl;
  return 0;
}
