//============================================================================
// Name : POJ_2940.cpp
// Author : tiger
// Version :
// Copyright : Your copyright notice
// Description : 简单模拟即可可//============================================================================
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int s[100002];
int main() {
freopen("in","r",stdin);
int n,i;
int p = -1,q =-1;
long long ans;
while(scanf("%d",&n) && n)
{
for(i = 0; i < n; i++)
{
scanf("%d",s+i);
if(p < 0 && s[i] < 0)
p = i;
if(q < 0 && s[i]> 0)
q = i;
}
ans = 0;
p = -1;
q = -1;
while(p < n && q < n)
{
if( (s[p] + s[q]) >=0 )
{
s[q] += s[p];
ans += -s[p] * abs(p-q);
s[p] = 0;
}else
{
s[p] += s[q];
ans += s[q]*abs(p-q);
s[q] = 0;
}
while(s[p] >= 0 & p < n)
p++;
while(s[q] <= 0 && q < n)
q++;
}
printf("%lld/n",ans);
}
return 0;
}