/*
#include <iostream>
#define MAXSIZE 5
using namespace std;
int arr[MAXSIZE];
int top;
void input();
void output();
void view();
void input(int k){
if(top==MAXSIZE) {
cout << "stack is full";
return;
}
arr[top++] = k;
}
void output(){
if(top==0) {
cout << "stack is empty";
return;
}
top--;
cout << "output data is " << arr[top] << "deth";
arr[top] = 0;
}
void view(){
for(int i=0; i<MAXSIZE; i++) {
cout << i << ":" << arr[i] << "\n";
}
}
int main(){
top = 0;
int n, k, i;
for(;;) {
cout << "1:push, 2:pop, 3:view\n";
cin >> n;
switch(n) {
case 1:
cout << "input data : ";
cin >> k;
input(k);
break;
case 2:
output();
break;
case 3:
view();
break;
}
}
}
*/
/*
#include <iostream>
using namespace std;
int top;
int n;
int arr[1000000];
void input(int k){
arr[top++] = k;
}
void output(){
top--;
arr[top] = 0;
}
int main(){
top = 0;
int k;
cin >> n;
int sum;
sum = 0;
for(int i=0;i<n;i++) {
cin >> k;
if (k==0){
output();
}
else{
input(k);
}
}
for(int i=0; i<top; i++) {
sum += arr[i];
}
cout << sum;
}
*/
/*
#include <iostream>
using namespace std;
int top;
int n;
int arr[1000000];
void input(int k){
arr[top++] = k;
}
void output(){
top--;
cout << arr[top];
arr[top] = 0;
}
int main(){
top = 0;
int k;
cin >> n;
for(int i=0;i<n;i++) {
cin >> k;
input(k);
}
for (;top;){
output();
}
return 0;
}
*/