#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, A = 1e6 + 5;
int n, a[N], nxt[N];
unordered_map<int, stack<int> > buc;
bool tag[A];
int p[A];
vector<int> pri;
long long res = 0;
void init() {
  for (int i = 2; i < A; ++i) {
    if (!tag[i]) pri.push_back(i), p[i] = i;
    for (int j = 0; j < (int)pri.size(); ++j) {
      if (i * pri[j] >= A) break;
      tag[i * pri[j]] = true, p[i * pri[j]] = pri[j];
      if (i % pri[j] == 0) break;
    }
  }
}
void add(int i, int x) {
  nxt[i] = i;
  while (x > 1) buc[p[x]].push(i), x /= p[x];
}
void del(int i, int x) {
  nxt[i] = i;
  while (x > 1) {
    if (buc[p[x]].empty())
      nxt[i] = 0;
    else
      nxt[i] = min(nxt[i], buc[p[x]].top()), buc[p[x]].pop();
    x /= p[x];
  }
}
struct Seg_Tree {
  struct Node {
    int data;
  } tr[N << 2];
  void up(int u) { tr[u].data = min(tr[u << 1].data, tr[u << 1 | 1].data); }
  void modify(int u, int l, int r, int x, int z) {
    if (l == r) return tr[u].data = z, void();
    int mid = (l + r) >> 1;
    if (x <= mid)
      return modify(u << 1, l, mid, x, z), up(u);
    else
      return modify(u << 1 | 1, mid + 1, r, x, z), up(u);
  }
  int query(int u, int l, int r, int x, int y, int z) {
    int mid = (l + r) >> 1, res = n + 1;
    if (x <= l && r <= y) {
      if (tr[u].data >= z) return n + 1;
      if (l == r) return l;
      if (tr[u << 1].data < z)
        return query(u << 1, l, mid, x, y, z);
      else
        return query(u << 1 | 1, mid + 1, r, x, y, z);
    }
    if (x <= mid) res = query(u << 1, l, mid, x, y, z);
    if (res != n + 1) return res;
    if (y > mid) res = query(u << 1 | 1, mid + 1, r, x, y, z);
    return res;
  }
} t;
int main() {
  init(), cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    char c = getchar();
    while (c != '*' && c != '/') c = getchar();
    if (c == '*')
      add(i, a[i]);
    else
      del(i, a[i]);
  }
  for (int i = 1; i <= n; ++i) t.modify(1, 1, n, i, nxt[i]);
  for (int i = 1; i <= n; ++i) res += t.query(1, 1, n, i, n, i) - i;
  return printf("%lld\n", res), 0;
}

### Prompt

Create a solution in Cpp for 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;
const int N = 1e6 + 5, A = 1e6 + 5;
int n, a[N], nxt[N];
unordered_map<int, stack<int> > buc;
bool tag[A];
int p[A];
vector<int> pri;
long long res = 0;
void init() {
  for (int i = 2; i < A; ++i) {
    if (!tag[i]) pri.push_back(i), p[i] = i;
    for (int j = 0; j < (int)pri.size(); ++j) {
      if (i * pri[j] >= A) break;
      tag[i * pri[j]] = true, p[i * pri[j]] = pri[j];
      if (i % pri[j] == 0) break;
    }
  }
}
void add(int i, int x) {
  nxt[i] = i;
  while (x > 1) buc[p[x]].push(i), x /= p[x];
}
void del(int i, int x) {
  nxt[i] = i;
  while (x > 1) {
    if (buc[p[x]].empty())
      nxt[i] = 0;
    else
      nxt[i] = min(nxt[i], buc[p[x]].top()), buc[p[x]].pop();
    x /= p[x];
  }
}
struct Seg_Tree {
  struct Node {
    int data;
  } tr[N << 2];
  void up(int u) { tr[u].data = min(tr[u << 1].data, tr[u << 1 | 1].data); }
  void modify(int u, int l, int r, int x, int z) {
    if (l == r) return tr[u].data = z, void();
    int mid = (l + r) >> 1;
    if (x <= mid)
      return modify(u << 1, l, mid, x, z), up(u);
    else
      return modify(u << 1 | 1, mid + 1, r, x, z), up(u);
  }
  int query(int u, int l, int r, int x, int y, int z) {
    int mid = (l + r) >> 1, res = n + 1;
    if (x <= l && r <= y) {
      if (tr[u].data >= z) return n + 1;
      if (l == r) return l;
      if (tr[u << 1].data < z)
        return query(u << 1, l, mid, x, y, z);
      else
        return query(u << 1 | 1, mid + 1, r, x, y, z);
    }
    if (x <= mid) res = query(u << 1, l, mid, x, y, z);
    if (res != n + 1) return res;
    if (y > mid) res = query(u << 1 | 1, mid + 1, r, x, y, z);
    return res;
  }
} t;
int main() {
  init(), cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    char c = getchar();
    while (c != '*' && c != '/') c = getchar();
    if (c == '*')
      add(i, a[i]);
    else
      del(i, a[i]);
  }
  for (int i = 1; i <= n; ++i) t.modify(1, 1, n, i, nxt[i]);
  for (int i = 1; i <= n; ++i) res += t.query(1, 1, n, i, n, i) - i;
  return printf("%lld\n", res), 0;
}

```