Zookeeper is buying a carton of fruit to feed his pet wabbit. The fruits are a sequence of apples and oranges, which is represented by a binary string s_1s_2… s_n of length n. 1 represents an apple and 0 represents an orange.

Since wabbit is allergic to eating oranges, Zookeeper would like to find the longest contiguous sequence of apples. Let f(l,r) be the longest contiguous sequence of apples in the substring s_{l}s_{l+1}… s_{r}. 

Help Zookeeper find ∑_{l=1}^{n} ∑_{r=l}^{n} f(l,r), or the sum of f across all substrings.

Input

The first line contains a single integer n (1 ≤ n ≤ 5 ⋅ 10^5).

The next line contains a binary string s of length n (s_i ∈ \{0,1\}) 

Output

Print a single integer: ∑_{l=1}^{n} ∑_{r=l}^{n} f(l,r). 

Examples

Input


4
0110


Output


12


Input


7
1101001


Output


30


Input


12
011100011100


Output


156

Note

In the first test, there are ten substrings. The list of them (we let [l,r] be the substring s_l s_{l+1} … s_r):

  * [1,1]: 0 
  * [1,2]: 01 
  * [1,3]: 011 
  * [1,4]: 0110 
  * [2,2]: 1 
  * [2,3]: 11 
  * [2,4]: 110 
  * [3,3]: 1 
  * [3,4]: 10 
  * [4,4]: 0 



The lengths of the longest contiguous sequence of ones in each of these ten substrings are 0,1,2,2,1,2,2,1,1,0 respectively. Hence, the answer is 0+1+2+2+1+2+2+1+1+0 = 12.
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int N = 5e5 + 10;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long long inf = 8e18;
const int LOG = 22;
long long pw(long long a, long long b, long long M) {
  return (!b ? 1
             : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M
                      : pw(a * a % M, b / 2, M)));
}
long long seg[4 * N], lz[4 * N], Ans[N], Nxt[N], Prv[N], ind[N], V[N];
void second(int v, int tl, int tr) {
  if (lz[v] == 0 || tl == tr) {
    return;
  }
  int mid = (tl + tr) >> 1;
  lz[v << 1] += lz[v];
  lz[v << 1 | 1] += lz[v];
  seg[v << 1] += 1ll * (mid - tl + 1) * lz[v];
  seg[v << 1 | 1] += 1ll * (tr - mid) * lz[v];
  lz[v] = 0;
}
void B(int v, int tl, int tr) {
  if (tl == tr) {
    seg[v] = V[tl];
    return;
  }
  int mid = (tl + tr) >> 1;
  B(v << 1, tl, mid);
  B(v << 1 | 1, mid + 1, tr);
  seg[v] = seg[v << 1] + seg[v << 1 | 1];
}
void U(int v, int tl, int tr, int l, int r, long long x) {
  if (l > r) return;
  second(v, tl, tr);
  if (tl == l && tr == r) {
    lz[v] += x;
    seg[v] += 1ll * (tr - tl + 1) * x;
    return;
  }
  int mid = (tl + tr) >> 1;
  if (l <= mid) {
    U(v << 1, tl, mid, l, min(r, mid), x);
  }
  if (r > mid) {
    U(v << 1 | 1, mid + 1, tr, max(mid + 1, l), r, x);
  }
  seg[v] = seg[v << 1] + seg[v << 1 | 1];
}
long long G(int v, int tl, int tr, int l, int r) {
  second(v, tl, tr);
  if (tl == l && tr == r) {
    return seg[v];
  }
  int mid = (tl + tr) >> 1;
  long long ans = 0;
  if (l <= mid) {
    ans = G(v << 1, tl, mid, l, min(r, mid));
  }
  if (r > mid) {
    ans += G(v << 1 | 1, mid + 1, tr, max(mid + 1, l), r);
  }
  return ans;
}
vector<pair<int, int> > Q[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  string s;
  cin >> n >> s;
  s = "." + s;
  for (int i = 1; i <= n; i++) {
    if (s[i] == '1') {
      Prv[i] = Prv[i - 1] + 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (s[i] == '1') {
      Nxt[i] = Nxt[i + 1] + 1;
      Q[i + Nxt[i]].push_back(make_pair(Nxt[i], i));
    }
  }
  deque<pair<int, int> > dq;
  for (int i = n; i >= 1; i--) {
    while (!dq.empty() && dq.front().first <= Prv[i]) {
      dq.pop_front();
    }
    for (auto cu : Q[i]) {
      int it = lower_bound((dq).begin(), (dq).end(), make_pair(cu.first, -1)) -
               dq.begin();
      if (it == (int)dq.size()) {
        Ans[cu.second] = n;
      } else {
        Ans[cu.second] = dq[it].second - 1;
      }
    }
    dq.push_front(make_pair(Prv[i], i));
  }
  for (int i = 1; i <= n; i++) {
    V[i] = max(V[i - 1], Prv[i]);
  }
  for (int i = 1; i <= n; i++) {
  }
  long long ans = 0;
  B(1, 1, n);
  for (int i = 1; i <= n; i++) {
    Ans[i] = max(Ans[i], i + Nxt[i] - 1);
    long long cu = G(1, 1, n, i, n);
    ans += cu;
    if (s[i] == '1') {
      U(1, 1, n, i, Ans[i], -1);
    }
  }
  cout << "\n";
  cout << ans << "\n";
  return 0;
}
