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 namespace std;
template <typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
  return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
class SegmentTree {
 public:
  struct Node {
    ll Sum = 0;
    int Max = 0;
    int Push = 0;
    int PushMax = 0;
  };
  explicit SegmentTree(int n) : tree(n << 2), size(n) {}
  void Update(int l, int r, int x) { UpdateImpl(0, 0, size - 1, l, r, x); }
  void Set(int l, int r, int x) { SetImpl(0, 0, size - 1, l, r, x); }
  ll Sum(int l, int r) { return SumImpl(0, 0, size - 1, l, r); }
  int Find(int val) { return FindImpl(0, 0, size - 1, val); }

 private:
  int Left(int v) const { return (v << 1) + 1; }
  int Right(int v) const { return (v << 1) + 2; }
  void UpdateVertex(int v) {
    tree[v].Sum = tree[Left(v)].Sum + tree[Right(v)].Sum;
    tree[v].Max = max(tree[Left(v)].Max, tree[Right(v)].Max);
  }
  void Push(int v, int tl, int tr) {
    const int mid = (tl + tr) >> 1;
    if (tree[v].PushMax != 0) {
      tree[Left(v)].Sum = 1LL * tree[v].PushMax * (mid - tl + 1);
      tree[Left(v)].Max = tree[v].PushMax;
      tree[Left(v)].Push = 0;
      tree[Left(v)].PushMax = tree[v].PushMax;
      tree[Right(v)].Sum = 1LL * tree[v].PushMax * (tr - mid);
      tree[Right(v)].Max = tree[v].PushMax;
      tree[Right(v)].Push = 0;
      tree[Right(v)].PushMax = tree[v].PushMax;
      tree[v].PushMax = 0;
    }
    if (tree[v].Push != 0) {
      tree[Left(v)].Sum += 1LL * tree[v].Push * (mid - tl + 1);
      tree[Left(v)].Max += tree[v].Push;
      tree[Left(v)].Push += tree[v].Push;
      tree[Right(v)].Sum += 1LL * tree[v].Push * (tr - mid);
      tree[Right(v)].Max += tree[v].Push;
      tree[Right(v)].Push += tree[v].Push;
      tree[v].Push = 0;
    }
  }
  void UpdateImpl(int v, int tl, int tr, int l, int r, int x) {
    if (l > r) {
      return;
    }
    if (tl == l && r == tr) {
      tree[v].Sum += x * (tr - tl + 1);
      tree[v].Max += x;
      tree[v].Push += x;
      return;
    }
    Push(v, tl, tr);
    const int mid = (tl + tr) >> 1;
    UpdateImpl(Left(v), tl, mid, l, min(mid, r), x);
    UpdateImpl(Right(v), mid + 1, tr, max(l, mid + 1), r, x);
    UpdateVertex(v);
  }
  void SetImpl(int v, int tl, int tr, int l, int r, int x) {
    if (l > r) {
      return;
    }
    if (tl == l && r == tr) {
      tree[v].Sum = 1LL * x * (tr - tl + 1);
      tree[v].Max = x;
      tree[v].Push = 0;
      tree[v].PushMax = x;
      return;
    }
    Push(v, tl, tr);
    const int mid = (tl + tr) >> 1;
    SetImpl(Left(v), tl, mid, l, min(mid, r), x);
    SetImpl(Right(v), mid + 1, tr, max(l, mid + 1), r, x);
    UpdateVertex(v);
  }
  ll SumImpl(int v, int tl, int tr, int l, int r) {
    if (l > r) {
      return 0;
    }
    if (tl == l && r == tr) {
      return tree[v].Sum;
    }
    Push(v, tl, tr);
    const int mid = (tl + tr) >> 1;
    return SumImpl(Left(v), tl, mid, l, min(mid, r)) +
           SumImpl(Right(v), mid + 1, tr, max(l, mid + 1), r);
  }
  int FindImpl(int v, int tl, int tr, int val) {
    if (tl == tr) {
      return tl;
    }
    Push(v, tl, tr);
    const int mid = (tl + tr) >> 1;
    if (tree[Left(v)].Max >= val) {
      return FindImpl(Left(v), tl, mid, val);
    }
    return FindImpl(Right(v), mid + 1, tr, val);
  }
  vector<Node> tree;
  const int size;
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;
  SegmentTree st(n);
  ll ans = 0;
  ll pre = 0;
  int cur = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '0') {
      ans += pre;
      cur = 0;
      continue;
    }
    ++cur;
    st.Set(i + cur, st.Find(cur), cur);
    st.Update(i, i + cur - 1, 1);
    pre = st.Sum(i, n - 1);
    ans += pre;
  }
  cout << ans << "\n";
  return 0;
}
