Water…
模拟…
#include <iostream>
using namespace std;
int main()
{
int ans = 0;
int ls = 0;
int x;
while(scanf("%d",&x) && x)
{
if(x == 1)
ans += x,ls = x;
else if(x == 2)
{
if(ls == 1)
ans += 2,ls = 2;
else
ans += ls+2,ls += 2;
}
}
cout<<ans;
return 0;
}