#include <bits/stdc++.h>
using namespace std;
bool home = 1;
const int N = (int)1e6 + 7;
int n, a[N], b[N], lim[4 * N];
vector<int> primes;
int lp[N];
void build(int v, int tl, int tr) {
  lim[v] = n;
  if (tl < tr) {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
  }
}
void force(int v, int tl, int tr, int l, int r, int x) {
  if (tr < l || r < tl) return;
  if (l <= tl && tr <= r) {
    lim[v] = min(lim[v], x);
    return;
  }
  int tm = (tl + tr) / 2;
  force(2 * v, tl, tm, l, r, x);
  force(2 * v + 1, tm + 1, tr, l, r, x);
}
void force(int l, int r, int x) { force(1, 1, n, l, r, x); }
int get(int v, int tl, int tr, int i) {
  if (tr < i || i < tl) return n;
  int sol = lim[v];
  if (tl < tr) {
    int tm = (tl + tr) / 2;
    sol = min(sol, get(2 * v, tl, tm, i));
    sol = min(sol, get(2 * v + 1, tm + 1, tr, i));
  }
  return sol;
}
vector<pair<int, int>> cool[N];
int cur[N], suf[N], first[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  home = 0;
  if (home) {
    freopen("input", "r", stdin);
  }
  for (int i = 2; i < N; i++) {
    if (lp[i] == 0) {
      lp[i] = i;
      primes.push_back(i);
    }
    for (int j = 0;
         j < (int)primes.size() && primes[j] <= lp[i] && primes[j] * i < N;
         j++) {
      lp[primes[j] * i] = primes[j];
    }
  }
  cin >> n;
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int num = a[i];
    while (num > 1) {
      int p = lp[num], cnt = 0;
      while (num % p == 0) {
        num /= p;
        cnt++;
      }
      cool[p].push_back({i, cnt});
    }
  }
  {
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++) {
      char ch = s[i - 1];
      assert(ch == '*' || ch == '/');
      if (ch == '*')
        b[i] = 1;
      else
        b[i] = 2;
    }
  }
  for (int p = 1; p < N; p++) {
    if (cool[p].empty()) continue;
    assert(lp[p] == p);
    vector<int> pos;
    for (auto &it : cool[p]) {
      pos.push_back(it.first);
      if (b[it.first] == 1)
        cur[it.first] = it.second;
      else
        cur[it.first] = -it.second;
    }
    int y = (int)pos.size();
    vector<pair<int, int>> segs;
    if (pos[0] > 1) {
      segs.push_back({1, pos[0] - 1});
    }
    for (int i = 0; i + 1 < y; i++) {
      segs.push_back({pos[i], pos[i + 1] - 1});
    }
    segs.push_back({pos[y - 1], n});
    {
      int sz = 0;
      for (auto &it : segs) sz += it.second - it.first + 1;
      assert(sz == n);
      assert(segs[0].first == 1);
      assert(segs.back().second == n);
      for (int i = 0; i + 1 < (int)segs.size(); i++) {
        assert(segs[i].second + 1 == segs[i + 1].first);
      }
    }
    y = (int)segs.size();
    suf[y] = 0;
    for (int i = y - 1; i >= 0; i--) {
      suf[i] = suf[i + 1] + cur[segs[i].first];
    }
    vector<int> stk;
    for (int i = y; i >= 0; i--) {
      while (!stk.empty() && suf[i] >= suf[stk.back()]) stk.pop_back();
      if (stk.empty())
        first[i] = -1;
      else
        first[i] = stk.back();
      stk.push_back(i);
    }
    for (int i = y - 1; i >= 0; i--) {
      if (first[i] != -1) {
        int j = first[i];
        assert(suf[i] < suf[j]);
        force(segs[i].first, segs[i].first, segs[j - 1].first - 1);
      }
      if (segs[i].first + 1 <= segs[i].second) {
        if (first[i + 1] != -1) {
          int j = first[i + 1];
          force(segs[i].first + 1, segs[i].second, segs[j - 1].first - 1);
        }
      }
    }
    for (auto &it : cool[p]) {
      cur[it.first] = 0;
    }
  }
  long long sol = 0;
  for (int i = 1; i <= n; i++) {
    int r = get(1, 1, n, i);
    if (r >= i) {
      sol += r - i + 1;
    }
  }
  cout << sol << "\n";
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

Kuzya started going to school. He was given math homework in which he was given an array a of length n and an array of symbols b of length n, consisting of symbols '*' and '/'.

Let's denote a path of calculations for a segment [l; r] (1 ≤ l ≤ r ≤ n) in the following way: 

  * Let x=1 initially. For every i from l to r we will consequently do the following: if b_i= '*', x=x*a_i, and if b_i= '/', then x=(x)/(a_i). Let's call a path of calculations for the segment [l; r] a list of all x that we got during the calculations (the number of them is exactly r - l + 1). 



For example, let a=[7, 12, 3, 5, 4, 10, 9], b=[/, *, /, /, /, *, *], l=2, r=6, then the path of calculations for that segment is [12, 4, 0.8, 0.2, 2].

Let's call a segment [l;r] simple if the path of calculations for it contains only integer numbers. 

Kuzya needs to find the number of simple segments [l;r] (1 ≤ l ≤ r ≤ n). Since he obviously has no time and no interest to do the calculations for each option, he asked you to write a program to get to find that number!

Input

The first line contains a single integer n (2 ≤ n ≤ 10^6).

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^6).

The third line contains n symbols without spaces between them — the array b_1, b_2 … b_n (b_i= '/' or b_i= '*' for every 1 ≤ i ≤ n).

Output

Print a single integer — the number of simple segments [l;r].

Examples

Input


3
1 2 3
*/*


Output


2


Input


7
6 4 10 1 2 15 1
*/*/*//


Output


8

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool home = 1;
const int N = (int)1e6 + 7;
int n, a[N], b[N], lim[4 * N];
vector<int> primes;
int lp[N];
void build(int v, int tl, int tr) {
  lim[v] = n;
  if (tl < tr) {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
  }
}
void force(int v, int tl, int tr, int l, int r, int x) {
  if (tr < l || r < tl) return;
  if (l <= tl && tr <= r) {
    lim[v] = min(lim[v], x);
    return;
  }
  int tm = (tl + tr) / 2;
  force(2 * v, tl, tm, l, r, x);
  force(2 * v + 1, tm + 1, tr, l, r, x);
}
void force(int l, int r, int x) { force(1, 1, n, l, r, x); }
int get(int v, int tl, int tr, int i) {
  if (tr < i || i < tl) return n;
  int sol = lim[v];
  if (tl < tr) {
    int tm = (tl + tr) / 2;
    sol = min(sol, get(2 * v, tl, tm, i));
    sol = min(sol, get(2 * v + 1, tm + 1, tr, i));
  }
  return sol;
}
vector<pair<int, int>> cool[N];
int cur[N], suf[N], first[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  home = 0;
  if (home) {
    freopen("input", "r", stdin);
  }
  for (int i = 2; i < N; i++) {
    if (lp[i] == 0) {
      lp[i] = i;
      primes.push_back(i);
    }
    for (int j = 0;
         j < (int)primes.size() && primes[j] <= lp[i] && primes[j] * i < N;
         j++) {
      lp[primes[j] * i] = primes[j];
    }
  }
  cin >> n;
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int num = a[i];
    while (num > 1) {
      int p = lp[num], cnt = 0;
      while (num % p == 0) {
        num /= p;
        cnt++;
      }
      cool[p].push_back({i, cnt});
    }
  }
  {
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++) {
      char ch = s[i - 1];
      assert(ch == '*' || ch == '/');
      if (ch == '*')
        b[i] = 1;
      else
        b[i] = 2;
    }
  }
  for (int p = 1; p < N; p++) {
    if (cool[p].empty()) continue;
    assert(lp[p] == p);
    vector<int> pos;
    for (auto &it : cool[p]) {
      pos.push_back(it.first);
      if (b[it.first] == 1)
        cur[it.first] = it.second;
      else
        cur[it.first] = -it.second;
    }
    int y = (int)pos.size();
    vector<pair<int, int>> segs;
    if (pos[0] > 1) {
      segs.push_back({1, pos[0] - 1});
    }
    for (int i = 0; i + 1 < y; i++) {
      segs.push_back({pos[i], pos[i + 1] - 1});
    }
    segs.push_back({pos[y - 1], n});
    {
      int sz = 0;
      for (auto &it : segs) sz += it.second - it.first + 1;
      assert(sz == n);
      assert(segs[0].first == 1);
      assert(segs.back().second == n);
      for (int i = 0; i + 1 < (int)segs.size(); i++) {
        assert(segs[i].second + 1 == segs[i + 1].first);
      }
    }
    y = (int)segs.size();
    suf[y] = 0;
    for (int i = y - 1; i >= 0; i--) {
      suf[i] = suf[i + 1] + cur[segs[i].first];
    }
    vector<int> stk;
    for (int i = y; i >= 0; i--) {
      while (!stk.empty() && suf[i] >= suf[stk.back()]) stk.pop_back();
      if (stk.empty())
        first[i] = -1;
      else
        first[i] = stk.back();
      stk.push_back(i);
    }
    for (int i = y - 1; i >= 0; i--) {
      if (first[i] != -1) {
        int j = first[i];
        assert(suf[i] < suf[j]);
        force(segs[i].first, segs[i].first, segs[j - 1].first - 1);
      }
      if (segs[i].first + 1 <= segs[i].second) {
        if (first[i + 1] != -1) {
          int j = first[i + 1];
          force(segs[i].first + 1, segs[i].second, segs[j - 1].first - 1);
        }
      }
    }
    for (auto &it : cool[p]) {
      cur[it.first] = 0;
    }
  }
  long long sol = 0;
  for (int i = 1; i <= n; i++) {
    int r = get(1, 1, n, i);
    if (r >= i) {
      sol += r - i + 1;
    }
  }
  cout << sol << "\n";
  return 0;
}

```