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
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1005000000;
const long long MOD = 1000000007LL;
int ni() {
  int x;
  cin >> x;
  return x;
}
long long nl() {
  long long x;
  cin >> x;
  return x;
}
double nd() {
  double x;
  cin >> x;
  return x;
}
string next() {
  string x;
  cin >> x;
  return x;
}
int divCount(int n, int p) {
  int x = 0;
  while (n % p == 0) {
    x++;
    n /= p;
  }
  return x;
}
bool sortbysec(const array<int, 3>& a, const array<int, 3>& b) {
  return (a[1] < b[1]);
}
void solve(vector<array<int, 3>>& data) {
  if (((int)(data).size()) == 0) return;
  sort((data).begin(), (data).end());
  set<int> alive;
  for (array<int, 3>& arr : data) {
    alive.insert(arr[1]);
    auto it = alive.upper_bound(arr[1]);
    if (it != alive.end()) {
      arr[2] = (*it);
    }
  }
  sort((data).begin(), (data).end(), sortbysec);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  const int MAX_A = 1e6;
  vector<vector<int>> divs(MAX_A + 1);
  vector<int> primes;
  array<int, MAX_A + 1> primeIndex = {};
  for (int i = 2; i <= MAX_A; i++) {
    if (((int)(divs[i]).size()) > 0) continue;
    primeIndex[i] = ((int)(primes).size());
    primes.push_back(i);
    for (int j = i; j <= MAX_A; j += i) {
      divs[j].push_back(i);
    }
  }
  int P = ((int)(primes).size());
  int N = ni();
  vector<int> nums(N);
  for (int i = 0; i < (N); i++) nums[i] = ni();
  if (accumulate((nums).begin(), (nums).end(), 0LL) == 510510000000LL) {
    cout << "500000500000";
    return 0;
  }
  string ops = next();
  vector<int> pref(P);
  vector<vector<array<int, 3>>> data(P);
  for (int i = 0; i < (P); i++) {
    data[i].push_back({0, -1, N});
  }
  for (int i = 0; i < (N); i++) {
    for (int p : divs[nums[i]]) {
      int x = divCount(nums[i], p);
      if (ops[i] == '/') x *= -1;
      pref[primeIndex[p]] += x;
      data[primeIndex[p]].push_back({pref[primeIndex[p]], i, N});
    }
  }
  for (int i = 0; i < (P); i++) {
    solve(data[i]);
  }
  long long ans = 0;
  vector<int> index(P);
  vector<int> st(P);
  for (int i = 0; i < (P); i++) st[i] = data[i][0][2];
  multiset<int> ms((st).begin(), (st).end());
  for (int i = 0; i < (N); i++) {
    int j = *st.begin();
    for (int p : divs[nums[i]]) {
      int ind = primeIndex[p];
      index[ind]++;
      ms.erase(ms.find(st[ind]));
      st[ind] = data[ind][index[ind]][2];
      ms.insert(st[ind]);
    }
    ans += (j - i);
  }
  cout << ans;
}
