/*#include <string.h>
int stack[100000]={};
int top=-1;
void push(int x)
{
top ++;
stack[top]=x;
}
//void pop() //
//{
// if(top==-1) return ;
// printf("%d",stack[top]);
// top--;
//}
int pop()
{
if(top==-1) return 0;
top--;
return stack[top+1];
}
int main ()
{
int i, n, a, sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a);
if(a==0)
{
pop();
}
else
{
push(a);
}
}
while(top != -1) // 스택이 비어있지 않다면
{
sum=sum+pop ();
}
printf("%d",sum);
return 0;
}*/
/*
#include<string.h>
char stack[100000]={};
int top=-1;
void push(char x)
{
top++;
stack[top]=x;
}
void pop()
{
if(top==-1) return ;
printf("%c",stack[top]);
top--;
}
int main()
{
char str[1001]={};
int i,n,c=0;
scanf("%d\n%s",&n,str);
for(i=n-1;i>=0;i--)
{
push(str[i]);
c++;
//push를 3번 했으면, ','를 push
if(c%3==0 && i!=0)
{
push(',');
}
}
while(top!=-1)
{
pop();
}
return 0;
}
*/