#include <bits/stdc++.h>
using namespace std;
int k, n1, n2, n3;
long long t1, t2, t3;
long long res;
class heap {
 public:
  int n, t;
  long long a[1003];
  heap(int num) {
    n = num;
    memset(a, 0, sizeof(a));
  }
  void upheap(int i) {
    int j = i / 2;
    if (j < 1) return;
    if (a[i] < a[j]) {
      long long t = a[i];
      a[i] = a[j];
      a[j] = t;
      upheap(j);
    }
  }
  void dnheap(int i) {
    int j = i * 2;
    if (j > n) return;
    if (j < n)
      if (a[j + 1] < a[j]) j++;
    if (a[i] > a[j]) {
      long long t = a[i];
      a[i] = a[j];
      a[j] = t;
      dnheap(j);
    }
  }
  long long getmin() { return a[1]; }
  void setmax(long long v) {
    a[1] = v;
    dnheap(1);
  }
};
void process() {
  res = 0;
  heap w(n1), d(n2), f(n3);
  long long x1, x2, x3, y1, y2, y3;
  for (int i = 0; i < k; i++) {
    x1 = w.getmin();
    x2 = d.getmin();
    x3 = f.getmin();
    y1 = x1 + t1;
    y2 = y1 + t2;
    y3 = y2 + t3;
    if ((y1 - t1 >= x1) && (y2 - t2 >= x2) && (y3 - t3 >= x3)) {
      w.setmax(y1);
      d.setmax(y2);
      f.setmax(y3);
      res = y3;
      continue;
    }
    y2 = x2 + t2;
    y1 = x2;
    y3 = y2 + t3;
    if ((y1 - t1 >= x1) && (y2 - t2 >= x2) && (y3 - t3 >= x3)) {
      w.setmax(y1);
      d.setmax(y2);
      f.setmax(y3);
      res = y3;
      continue;
    }
    y3 = x3 + t3;
    y2 = x3;
    y1 = y2 - t2;
    if ((y1 - t1 >= x1) && (y2 - t2 >= x2) && (y3 - t3 >= x3)) {
      w.setmax(y1);
      d.setmax(y2);
      f.setmax(y3);
      res = y3;
      continue;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  process();
  cout << res;
  return 0;
}
