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;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using si = set<int>;
using sl = set<ll>;
template <typename T, class F = function<T(T, T)>>
struct DO {
  vector<T> mas;
  vi pos;
  F upd, chg;
  T inf;
  int siz;
  DO(const int &n, const T &neu, const F &u, const F &c)
      : siz(n), upd(u), chg(c), inf(neu) {
    mas.assign(n * 4 + 5, neu);
    pos.resize(n * 4 + 5);
  }
  void modify(int i, int tl, int tr, int id, T value) {
    if (tl + 1 == tr) {
      mas[i] = chg(mas[i], value);
      pos[i] = tl;
      return;
    }
    int mid = (tl + tr) / 2;
    if (id < mid) {
      modify(i * 2, tl, mid, id, value);
    } else {
      modify(i * 2 + 1, mid, tr, id, value);
    }
    mas[i] = upd(mas[i * 2], mas[i * 2 + 1]);
    if (mas[i] == mas[i * 2 + 1]) {
      pos[i] = pos[i * 2 + 1];
    }
  }
  void modify(int point, T value) { modify(1, 0, siz, point, value); }
  T getValue(int i, int tl, int tr, int l, int r) {
    if (l <= tl && tr <= r) {
      return mas[i];
    }
    if (tl >= r || l >= tr) {
      return inf;
    }
    int mid = (tl + tr) / 2;
    return upd(getValue(i * 2, tl, mid, l, r),
               getValue(i * 2 + 1, mid, tr, l, r));
  }
  T getValue(int l, int r) { return getValue(1, 0, siz, l, r + 1); }
  pair<T, int> getValueWithIndex(int i, int tl, int tr, int l, int r) {
    if (l <= tl && tr <= r) {
      return {mas[i], pos[i]};
    }
    if (tl >= r || l >= tr) return {inf, inf};
    int mid = (tl + tr) / 2;
    auto le = getValueWithIndex(i * 2, tl, mid, l, r);
    auto re = getValueWithIndex(i * 2 + 1, mid, tr, l, r);
    if (upd(le.first, re.first) == le.first) return le;
    return re;
  }
  pair<T, int> getValueWithIndex(int l, int r) {
    return getValueWithIndex(1, 0, siz, l, r + 1);
  }
};
int n;
string s;
ll res;
const int N = 500005;
ll t[4 * N], equ[4 * N];
void push(int i, int tl, int tr) {
  if (equ[i] == -1) return;
  t[i] = (tr - tl) * equ[i];
  if (tl + 1 != tr) {
    equ[i * 2] = equ[i * 2 + 1] = equ[i];
  }
  equ[i] = -1;
}
void modify(int i, int tl, int tr, int l, int r, int v) {
  push(i, tl, tr);
  if (l <= tl && tr <= r) {
    equ[i] = v;
    push(i, tl, tr);
    return;
  }
  if (tl >= r || l >= tr) return;
  int m = (tl + tr) / 2;
  modify(i * 2, tl, m, l, r, v);
  modify(i * 2 + 1, m, tr, l, r, v);
  t[i] = t[i * 2] + t[i * 2 + 1];
}
ll get(int i, int tl, int tr, int l, int r) {
  push(i, tl, tr);
  if (l <= tl && tr <= r) return t[i];
  if (tl >= r || l >= tr) return 0;
  int m = (tl + tr) / 2;
  return get(i * 2, tl, m, l, r) + get(i * 2 + 1, m, tr, l, r);
}
void solve() {
  fill(equ, equ + 4 * N, -1);
  cin >> s >> s;
  n = (int)s.size();
  ll res = 0;
  ll curLen = 0;
  ll curAdd = 0;
  DO<int> posTree(
      n + 2, 2e9, [](int a, int b) { return min(a, b); },
      [](int a, int b) { return min(a, b); });
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '0') {
      for (int j = i + 1; j <= i + curLen; ++j)
        modify(1, 0, n, j, j + 1, j - (i + 1) + 1);
      if (curLen) {
        posTree.modify(curLen, i + 1);
      }
      curLen = 0;
      curAdd = 0;
      res += get(1, 0, n, i + 1, n);
    } else {
      curLen++;
      curAdd += curLen;
      auto p = posTree.getValueWithIndex(curLen + 1, n + 2);
      int nxt;
      if (p.second == 2e9) {
        nxt = n;
      } else {
        nxt = p.first + curLen - 1;
      }
      modify(1, 0, n, i + curLen, nxt, curLen);
      res += curAdd + get(1, 0, n, i + curLen, n);
    }
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
