#include<stdio.h>
int main()
{
int n,t,sum,b,c,s,i;
while(scanf("%d",&n)&&n)
{
sum=0;
for(i=0;i<n;i++)
{
scanf("%d",&t);
b=t/5;
c=t%5;
if(b>=20)
{
s=b/20;
sum+=s;
b%=20;
}
if(b>=10)
{
s=b/10;
sum+=s;
b%=10;
}
if(b>=2)
{
s=b/2;
sum+=s;
b%=2;
}
if(b==1)
sum++;
if(c==4||c==3)
sum+=2;
else if(c==1||c==2)
sum++;
}
printf("%d\n",sum);
}
return 0;
}
int main()
{
int n,t,sum,b,c,s,i;
while(scanf("%d",&n)&&n)
{
sum=0;
for(i=0;i<n;i++)
{
scanf("%d",&t);
b=t/5;
c=t%5;
if(b>=20)
{
s=b/20;
sum+=s;
b%=20;
}
if(b>=10)
{
s=b/10;
sum+=s;
b%=10;
}
if(b>=2)
{
s=b/2;
sum+=s;
b%=2;
}
if(b==1)
sum++;
if(c==4||c==3)
sum+=2;
else if(c==1||c==2)
sum++;
}
printf("%d\n",sum);
}
return 0;
}