#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
struct Tree {
  int minn;
} st[1000005 * 4];
int n, m, size, a[1000005], f[1000005], vis[1000005], pri[1000005],
    last[1000005];
long long ans, g[1000005];
char s[1000005];
stack<int> e[100000];
inline void change(int node, int l, int r, int id, int k) {
  if (l == r) {
    st[node].minn = k;
    return;
  }
  int mid = (l + r) >> 1;
  if (id <= mid) {
    change(node << 1, l, mid, id, k);
  } else {
    change(node << 1 | 1, mid + 1, r, id, k);
  }
  st[node].minn = min(st[node << 1].minn, st[node << 1 | 1].minn);
  return;
}
inline int query(int node, int l, int r, int L, int R) {
  if (L >= l && R <= r) return st[node].minn;
  int mid = (L + R) >> 1;
  if (r <= mid) return query(node << 1, l, r, L, mid);
  if (l > mid) return query(node << 1 | 1, l, r, mid + 1, R);
  return min(query(node << 1, l, r, L, mid),
             query(node << 1 | 1, l, r, mid + 1, R));
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    f[i] = i;
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++)
    if (a[i] == 1) s[i] = '*';
  for (int i = 2; i <= 1000000; i++) {
    if (!vis[i]) {
      pri[++size] = i;
      vis[i] = size;
      last[i] = i;
    }
    for (int j = 1; j <= size && i * pri[j] <= 1000000; j++) {
      int k = i * pri[j];
      vis[k] = 1;
      last[k] = pri[j];
      if (i % pri[j] == 0) break;
    }
  }
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    if (s[i] == '*') {
      while (a[i] != 1) {
        e[vis[last[a[i]]]].push(i);
        a[i] = a[i] / last[a[i]];
      }
    } else {
      while (a[i] != 1) {
        if (e[vis[last[a[i]]]].empty()) {
          f[i] = 0;
        } else {
          f[i] = min(f[i], e[vis[last[a[i]]]].top());
          e[vis[last[a[i]]]].pop();
        }
        a[i] = a[i] / last[a[i]];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (f[i] && f[i] <= i - 1) f[i] = query(1, f[i], i - 1, 1, n);
    change(1, 1, n, i, f[i]);
  }
  g[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == '*') {
      g[i] = g[i - 1] + 1;
    } else {
      if (!f[i]) continue;
      g[i] = g[f[i] - 1] + 1;
    }
    ans += g[i];
  }
  writeln(ans);
  return 0;
}

### Prompt

Your task is to create a cpp solution to 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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
struct Tree {
  int minn;
} st[1000005 * 4];
int n, m, size, a[1000005], f[1000005], vis[1000005], pri[1000005],
    last[1000005];
long long ans, g[1000005];
char s[1000005];
stack<int> e[100000];
inline void change(int node, int l, int r, int id, int k) {
  if (l == r) {
    st[node].minn = k;
    return;
  }
  int mid = (l + r) >> 1;
  if (id <= mid) {
    change(node << 1, l, mid, id, k);
  } else {
    change(node << 1 | 1, mid + 1, r, id, k);
  }
  st[node].minn = min(st[node << 1].minn, st[node << 1 | 1].minn);
  return;
}
inline int query(int node, int l, int r, int L, int R) {
  if (L >= l && R <= r) return st[node].minn;
  int mid = (L + R) >> 1;
  if (r <= mid) return query(node << 1, l, r, L, mid);
  if (l > mid) return query(node << 1 | 1, l, r, mid + 1, R);
  return min(query(node << 1, l, r, L, mid),
             query(node << 1 | 1, l, r, mid + 1, R));
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    f[i] = i;
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++)
    if (a[i] == 1) s[i] = '*';
  for (int i = 2; i <= 1000000; i++) {
    if (!vis[i]) {
      pri[++size] = i;
      vis[i] = size;
      last[i] = i;
    }
    for (int j = 1; j <= size && i * pri[j] <= 1000000; j++) {
      int k = i * pri[j];
      vis[k] = 1;
      last[k] = pri[j];
      if (i % pri[j] == 0) break;
    }
  }
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    if (s[i] == '*') {
      while (a[i] != 1) {
        e[vis[last[a[i]]]].push(i);
        a[i] = a[i] / last[a[i]];
      }
    } else {
      while (a[i] != 1) {
        if (e[vis[last[a[i]]]].empty()) {
          f[i] = 0;
        } else {
          f[i] = min(f[i], e[vis[last[a[i]]]].top());
          e[vis[last[a[i]]]].pop();
        }
        a[i] = a[i] / last[a[i]];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (f[i] && f[i] <= i - 1) f[i] = query(1, f[i], i - 1, 1, n);
    change(1, 1, n, i, f[i]);
  }
  g[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == '*') {
      g[i] = g[i - 1] + 1;
    } else {
      if (!f[i]) continue;
      g[i] = g[f[i] - 1] + 1;
    }
    ans += g[i];
  }
  writeln(ans);
  return 0;
}

```