#include #include #include #include using namespace std; #ifdef HOME_DEBUG static std::ifstream input ("input.txt"); static std::ofstream output("output.txt"); #else static std::istream& input = std::cin; static std::ostream& output = std::cout; #endif std::map cache; //int64_t cache[1000000]={}; int64_t wrk(int64_t x){ if(x==1) return 1; // if(x<_countof(cache) && cache[x]!=0) // return cache[x]; auto pos=cache.find(x); if(pos!=cache.end()) return pos->second; int64_t v=1+x; int64_t max=std::sqrt(x)+2; if(max>x) max=x; for(int64_t d=2;dv) v=nv1; if(nv2>v) v=nv2; } //if(x<_countof(cache)) cache[x]=v; return v; } int main() { int n; input >> n; int64_t ret=0,x; for(int i=0;i> x; //cache.clear(); ret += wrk(x); } output << ret << endl; return 0; }