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>
using i32 = int;
using i64 = long long;
struct Node {
  i64 sum;
  i32 set_tag, add_tag, minimum, lo, hi;
  void set(i32 tag) {
    set_tag = tag;
    minimum = tag;
    sum = 1ll * (hi - lo) * tag;
  }
  void add(i32 tag) {
    add_tag += tag;
    minimum += tag;
    sum += 1ll * (hi - lo) * tag;
  }
  void push_down(Node& left, Node& right) {
    if (set_tag != -1) {
      left.set(set_tag);
      right.set(set_tag);
      set_tag = -1;
    }
    if (add_tag != 0) {
      left.add(add_tag);
      right.add(add_tag);
      add_tag = 0;
    }
  }
  void maintain(Node& left, Node& right) {
    sum = left.sum + right.sum;
    minimum = std::min(left.minimum, right.minimum);
  }
};
Node make_node(i32 x, i32 lo, i32 hi) { return {x, -1, 0, x, lo, hi}; }
Node merge(Node& left, Node& right) {
  assert(left.hi == right.lo);
  i64 sum = left.sum + right.sum;
  i32 minimum = std::min(left.minimum, right.minimum);
  return {sum, -1, 0, minimum, left.lo, right.hi};
}
struct SegmentTree {
  std::vector<Node> tree;
  explicit SegmentTree(i32 n) : tree(n + n) {
    i32 k = 1;
    while (k < n) k = k + k;
    i32 m = n + n - k, s = k - n;
    for (i32 i = 0; i < m; i++) tree[i + k] = make_node(0, i, i + 1);
    for (i32 i = m; i < n; i++) tree[i + s] = make_node(0, i, i + 1);
    for (i32 i = n - 1; i; i--) tree[i] = merge(tree[i + i], tree[i + i + 1]);
  }
  template <class Fun>
  void update(i32 l, i32 r, Fun&& fun, i32 i = 1) {
    if (r <= tree[i].lo || tree[i].hi <= l) return;
    if (l <= tree[i].lo && tree[i].hi <= r) return fun(tree[i]);
    tree[i].push_down(tree[i + i], tree[i + i + 1]);
    update(l, r, fun, i + i + 0);
    update(l, r, fun, i + i + 1);
    tree[i].maintain(tree[i + i], tree[i + i + 1]);
  }
  i32 q(i32 p, i32 i = 1) {
    if (tree[i].lo + 1 == tree[i].hi) return tree[i].sum;
    return p < tree[i + i].hi ? q(p, i + i) : q(p, i + i + 1);
  }
  i32 find(i32 n, i32 x, i32 i = 1) {
    if (tree[i].lo + 1 == tree[i].hi) return tree[i].lo;
    tree[i].push_down(tree[i + i], tree[i + i + 1]);
    return tree[i + i].minimum < x || n < tree[i + i + 1].lo
               ? find(n, x, i + i)
               : find(n, x, i + i + 1);
  }
  i64 sum() { return tree[1].sum; }
};
i32 main() {
  std::ios::sync_with_stdio(false);
  std::cout.tie(nullptr);
  std::cin.tie(nullptr);
  i32 n;
  std::string s;
  std::cin >> n >> s;
  SegmentTree tree(n);
  i64 ans = 0;
  for (i32 i = 0, j = -1; i < n; i++) {
    if (s[i] == '0') {
      j = -1;
    } else {
      if (j == -1) j = i;
      tree.update(j, i + 1, [&](Node& node) { node.add(1); });
      i32 p = tree.find(j, i - j + 1);
      tree.update(p, j, [&](Node& node) { node.set(i - j + 1); });
    }
    ans += tree.sum();
  }
  std::cout << ans << "\n";
  return 0;
}
