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.
import java.io.*;
import java.util.*;

public class A {
	public static void main (String[] args) { new A(); }

	public A() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");
		
		int n = fs.nextInt();
		char[] str = fs.next().toCharArray();
		
		int[] longest = new int[n + 1];
		long[] dp = new long[n + 1];
		ArrayDeque<Integer> queue = new ArrayDeque<>();
		
		long res = 0;
		for(int i = n-1; i >= 0; i--) {
			if(str[i] == '0') {
				
				if(i+1 < n && str[i+1] == '1') { //chain finished
					addToQueue(queue, longest, i+1);
				}
				
				int better = oo;
				if(!queue.isEmpty()) better = queue.peekLast();
				
				if(better == oo) {
					dp[i] = 0;
				}
				else {
					dp[i] = dp[better];
				}
				
				res += dp[i];
				
			}
			else {
				
				long myAdd = 0;
				longest[i] = 1+longest[i+1];
				
				while(!queue.isEmpty()) {
					int who = queue.peekLast();
					if(longest[who] < longest[i]) queue.pollLast();
					else break;
				}
				
				myAdd += summ(longest[i]);
				int better = oo;
				if(!queue.isEmpty()) better = queue.peekLast();
				
				if(better == oo) {
					
					int len = n - (i+longest[i]);
					myAdd += len * (long)longest[i];
					
				}
				else {
					
					long get = dp[better];
					get -= summ(longest[i]);
					int pos1 = better+longest[i]-1;
					int pos2 = i+longest[i];
					
					get += (long)longest[i]*Math.max(0, pos1-pos2+1);
					
					myAdd += get;
				}
				
				dp[i] = myAdd;
				res += myAdd;

			}
		}
		
		out.println(res);
		
		out.close();
	}
	
	void addToQueue(ArrayDeque<Integer> dq, int[] longest, int i) {
		while(!dq.isEmpty()) {
			int who = dq.peekLast();
			if(longest[who] < longest[i]) dq.pollLast();
			else break;
		}
		dq.addLast(i);
	}
	
	long summ(long n) {
		return n * (n + 1) / 2;
	}
	
	int oo = (int)2e9;

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}