#include <stdio.h>
#include <math.h>

int main (void){

        int i,j,N;
        long  total = 0;

        scanf("%d",&N);
        
        int array[1000000] = {}; //配列
        
        for(i = 1; i<=N; i++){
                if(i % 3 != 0 && i % 5 != 0){
                        array[i-1] = i;
                }
                else{
                        array[i-1] = 0;
                }
        }

        for(j = 0; j < N; j++){
                printf("%d\n",array[j]);
                total = total +array[j];
        }

        printf("%ld\n",total);


        return 0;
}
