#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b=0,c;
cin>>a;
for(int i=1;i<=a;i=i+1){
if(i%2==1||i%3==1||i%5==1){
b+=i;
cout<<i<<endl;
}
}
cout<<b
}
/**************************************************************
Problem: 1983
User: zhengzihao
Language: C++
Result: Compile Error
****************************************************************/