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>
const int N = 500010;
const int inf = 0x3f3f3f3f;
const long long INF = 1ll << 60;
class SegmentTree {
 public:
  SegmentTree() {}
  void Init(int n, long long v[]) {
    n_ = n;
    Build(1, n, 1, v);
  }
  void IncreaseInterval(int l, int r, int rt, int L, int R, int x) {
    if (L > R) {
      return;
    }
    if (L <= l && r <= R) {
      cov_inc_[rt] += x;
      sum_[rt] += 1ll * x * (r - l + 1);
      return;
    }
    int m = (l + r) >> 1;
    Down(l, m, r, rt);
    if (L <= m) {
      IncreaseInterval(l, m, rt << 1, L, R, x);
    }
    if (R > m) {
      IncreaseInterval(m + 1, r, rt << 1 | 1, L, R, x);
    }
    Up(rt);
  }
  void ChangeInterval(int l, int r, int rt, int L, int R, int x) {
    if (L > R) {
      return;
    }
    if (L <= l && r <= R) {
      cov_cha_[rt] = x;
      cov_inc_[rt] = 0ll;
      sum_[rt] = 1ll * x * (r - l + 1);
      return;
    }
    int m = (l + r) >> 1;
    Down(l, m, r, rt);
    if (L <= m) {
      ChangeInterval(l, m, rt << 1, L, R, x);
    }
    if (R > m) {
      ChangeInterval(m + 1, r, rt << 1 | 1, L, R, x);
    }
    Up(rt);
  }
  long long SumInterval(int l, int r, int rt, int L, int R) {
    if (L > R) {
      return 0ll;
    }
    if (L <= l && r <= R) {
      return sum_[rt];
    }
    int m = (l + r) >> 1;
    Down(l, m, r, rt);
    long long ans = 0ll;
    if (L <= m) {
      ans += SumInterval(l, m, rt << 1, L, R);
    }
    if (R > m) {
      ans += SumInterval(m + 1, r, rt << 1 | 1, L, R);
    }
    return ans;
  }

 private:
  void Build(int l, int r, int rt, long long v[]) {
    cov_inc_[rt] = 0ll;
    cov_cha_[rt] = INF;
    if (l == r) {
      sum_[rt] = v[l];
      return;
    }
    int m = (l + r) >> 1;
    Build(l, m, rt << 1, v);
    Build(m + 1, r, rt << 1 | 1, v);
    Up(rt);
  }
  void Up(int rt) { sum_[rt] = sum_[rt << 1] + sum_[rt << 1 | 1]; }
  void Down(int l, int m, int r, int rt) {
    if (cov_cha_[rt] != INF) {
      cov_cha_[rt << 1] = cov_cha_[rt];
      cov_cha_[rt << 1 | 1] = cov_cha_[rt];
      cov_inc_[rt << 1] = 0ll;
      cov_inc_[rt << 1 | 1] = 0ll;
      sum_[rt << 1] = cov_cha_[rt] * (m - l + 1);
      sum_[rt << 1 | 1] = cov_cha_[rt] * (r - m);
      cov_cha_[rt] = INF;
    }
    if (cov_inc_[rt]) {
      cov_inc_[rt << 1] += cov_inc_[rt];
      cov_inc_[rt << 1 | 1] += cov_inc_[rt];
      sum_[rt << 1] += cov_inc_[rt] * (m - l + 1);
      sum_[rt << 1 | 1] += cov_inc_[rt] * (r - m);
      cov_inc_[rt] = 0ll;
    }
  }
  int n_;
  long long sum_[N << 2 | 1];
  long long cov_inc_[N << 2 | 1];
  long long cov_cha_[N << 2 | 1];
} seg;
int t;
int n;
char s[N];
std::vector<std::pair<int, int> > vec;
int pre_len1;
int pre_l1;
long long ans;
long long v[N];
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  vec.clear();
  seg.Init(n, v);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '0') {
      if (pre_len1) {
        vec.push_back(std::pair<int, int>(pre_len1, pre_l1));
        pre_len1 = 0;
      }
    } else {
      if (!pre_len1) {
        pre_l1 = i;
      }
      seg.IncreaseInterval(1, n, 1, pre_l1, i, 1);
      ++pre_len1;
      while (vec.size() && vec.back().first <= pre_len1) {
        vec.pop_back();
      }
      int l;
      if (vec.size()) {
        int len = vec.back().first;
        assert(len > pre_len1);
        int r = vec.back().second + len - 1;
        l = r - pre_len1 + 1;
      } else {
        l = 1;
      }
      seg.ChangeInterval(1, n, 1, l, pre_l1 - 1, pre_len1);
    }
    ans += seg.SumInterval(1, n, 1, 1, i);
  }
  printf("%lld\n", ans);
  return 0;
}
