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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class f {
	public static void main(String[] args) {
		FastScanner scan=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);

		/*
		solution idea
		we brute force the right pointer and add up all the answers for each substring ending at that point (r)
		if: r is the end of a sequence of 1's better than everything we've seen so far (length k)
		the answer is k*(r-k+2)+(k-1)+(k-2)+...+1
		
		otherwise we need to do a little thinking
		*/
		
		int n=scan.nextInt();
		char[] temp=scan.next().toCharArray();
		
		int[] a=new int[n];
		for(int i=0;i<n;i++) a[i]=(int)(temp[i]-'0');
		
		int[] st=new int[n];
		Arrays.fill(st,-1);
		
		int s=0;
		for(int i=n-1;i>=0;i--) {
			if(a[i]==1) s++;
			else s=0;
			st[i]=s;
		}
		
		int[] changedThisTime=new int[n+1];
		Arrays.fill(changedThisTime,-1);
		int time=0;
		
		long[] lastlast=new long[n+1];
		long[] lastStreak=new long[n+1];
		long curAnswer=0L;
		long res=0L;
		long maxStreak=0L;
		int streak=0;
		
		for(int r=0;r<n;r++) {
			if(a[r]==1) {
				streak++;
				if(streak>=maxStreak) {
					maxStreak=streak;
					curAnswer=((long)streak*((long)r-(long)streak+2))+tri(streak-1);
				}
				else {
					long last;
					if(changedThisTime[streak]==time) {
						last=lastlast[streak];
					}
					else last=lastStreak[streak];
					
//					System.out.println(last+" "+streak+" "+r);
//					System.out.println("val "+(r-(lastStreak[streak-1])));
					curAnswer-=((long)streak-1)*(r-last-1-((long)streak-1))+tri((long)streak-1);
					curAnswer+=((long)streak)*(r-last-1-((long)streak-1))+tri((long)streak);
				}
			}
			else {
				streak=0;
				time++;
			}
			lastlast[st[r]]=lastStreak[st[r]];
			lastStreak[st[r]]=r;
			
			changedThisTime[st[r]]=time;
			
//			System.out.println(curAnswer);
			res+=curAnswer;
		}
		out.println(res);
		out.close();
	}
	public static long tri(long x) {
		return x*(x+1)/2;
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

		public int nextInt() {return Integer.parseInt(next());}

		public long nextLong() {return Long.parseLong(next());}

		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}
	}
}