#include <bits/stdc++.h>
using namespace std;
const double INF = 1000000000;
const long long INFLL = 1000000000000000005ll;
const long long MOD = 1000000007;
enum { F1, F2, F3, Q1, Q2, Q3 };
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    E;
int K, N1, N2, N3, T1, T2, T3, W1, W2, W3;
int main() {
  cin >> K >> N1 >> N2 >> N3 >> T1 >> T2 >> T3;
  for (long long i = (1); i <= (K); i++) E.push({0, Q1});
  int ans;
  while (!E.empty()) {
    pair<int, int> p = E.top();
    E.pop();
    int id = p.second;
    int t = p.first;
    ans = t;
    if (id == Q1) {
      if (N1) {
        N1--;
        E.push({t + T1, F1});
      } else
        W1++;
    }
    if (id == F1) {
      N1++;
      E.push({t, Q2});
      if (W1) {
        E.push({t + T1, F1});
        W1--;
        N1--;
      }
    }
    if (id == Q2) {
      if (N2) {
        N2--;
        E.push({t + T2, F2});
      } else
        W2++;
    }
    if (id == F2) {
      N2++;
      E.push({t, Q3});
      if (W2) {
        E.push({t + T2, F2});
        W2--;
        N2--;
      }
    }
    if (id == Q3) {
      if (N3) {
        N3--;
        E.push({t + T3, F3});
      } else
        W3++;
    }
    if (id == F3) {
      N3++;
      if (W3) {
        E.push({t + T3, F3});
        W3--;
        N3--;
      }
    }
  }
  cout << ans << "\n";
}
