int main()
{
long n,k;
scanf("%ld\n",&n);
long a[n];
for(long i= 0;i<n;i++)
scanf("%ld\n",&a[i]);
for(long i=0;i<n;i++)
{
k=0;
for(long j=3;j<a[i];j++)
if(j%3==0 || j%5==0)
k=k+j;
if(k>0)
printf("%ld\n",k);
else
printf("%ld\n",k);
}
return 0;
}