import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  int[] t, a; readC(n, t, a);

  auto ta = new long[](n), aa = new long[](n);
  ta[0] = t[0]; aa[0] = a[0];

  foreach (i; 1..n) {
    auto k = max((ta[i-1]+t[i]-1)/t[i], (aa[i-1]+a[i]-1)/a[i]);
    ta[i] = k*t[i]; aa[i] = k*a[i];
  }

  writeln(ta[$-1]+aa[$-1]);
}
