#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int read() {
  int s = 0;
  char c = getchar(), lc = '+';
  while (c < '0' || '9' < c) lc = c, c = getchar();
  while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar();
  return lc == '-' ? -s : s;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + '0');
  else
    write(x / 10), putchar(x % 10 + '0');
}
void print(long long x, char c = '\n') {
  write(x);
  putchar(c);
}
void up(int &x, int y) {
  if (x > y) x = y;
}
int mn[N], a[N], nxt[N];
void ysgs(int n) {
  mn[1] = 1;
  for (int i = 2; i <= n; i++)
    if (!mn[i])
      for (int j = i; j <= n; j += i)
        if (!mn[j]) mn[j] = i;
}
char op[N];
vector<pair<int, int>> b[N];
signed main(signed Goodbye, char *Wangang[]) {
  (void)Goodbye, (void)Wangang;
  ysgs(1e6);
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  scanf("%s", op + 1);
  for (int i = 1; i <= n; i++) {
    nxt[i] = i;
    int now = a[i];
    while (now > 1)
      b[mn[now]].push_back(make_pair(op[i] == '*' ? 1 : -1, i)), now /= mn[now];
  }
  for (int t = 1; t <= 1e6; t++)
    if (!b[t].empty()) {
      stack<int> st;
      for (auto i : b[t])
        if (i.first > 0)
          st.push(i.second);
        else if (!st.empty())
          up(nxt[i.second], st.top()), st.pop();
        else
          nxt[i.second] = 0;
    }
  static int st[N], top = 0;
  st[0] = n + 1;
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    st[++top] = i;
    while (top && nxt[st[top]] >= i) top--;
    ans += st[top] - i;
  }
  print(ans);
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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;
int read() {
  int s = 0;
  char c = getchar(), lc = '+';
  while (c < '0' || '9' < c) lc = c, c = getchar();
  while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar();
  return lc == '-' ? -s : s;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + '0');
  else
    write(x / 10), putchar(x % 10 + '0');
}
void print(long long x, char c = '\n') {
  write(x);
  putchar(c);
}
void up(int &x, int y) {
  if (x > y) x = y;
}
int mn[N], a[N], nxt[N];
void ysgs(int n) {
  mn[1] = 1;
  for (int i = 2; i <= n; i++)
    if (!mn[i])
      for (int j = i; j <= n; j += i)
        if (!mn[j]) mn[j] = i;
}
char op[N];
vector<pair<int, int>> b[N];
signed main(signed Goodbye, char *Wangang[]) {
  (void)Goodbye, (void)Wangang;
  ysgs(1e6);
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  scanf("%s", op + 1);
  for (int i = 1; i <= n; i++) {
    nxt[i] = i;
    int now = a[i];
    while (now > 1)
      b[mn[now]].push_back(make_pair(op[i] == '*' ? 1 : -1, i)), now /= mn[now];
  }
  for (int t = 1; t <= 1e6; t++)
    if (!b[t].empty()) {
      stack<int> st;
      for (auto i : b[t])
        if (i.first > 0)
          st.push(i.second);
        else if (!st.empty())
          up(nxt[i.second], st.top()), st.pop();
        else
          nxt[i.second] = 0;
    }
  static int st[N], top = 0;
  st[0] = n + 1;
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    st[++top] = i;
    while (top && nxt[st[top]] >= i) top--;
    ans += st[top] - i;
  }
  print(ans);
  return 0;
}

```