#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n2, p, x, y, q, l, r, k, i, ans, t, n, j;
  ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    if (i != 0) {
      n2 = x;
      while (n2 <= p) {
        n2 += y;
      }
      ans += (n2 - p);
      p = n2;
    } else {
      ans = x;
      p = x;
    }
  }
  cout << ans << "\n";
  return 0;
}
