Răspuns :

#include <iostream>

#include <fstream>

size_t fn(size_t n) {

   size_t s = 0;

   while (n)

       s += 3 * n-- - 2;

   return s;

}

int main() {

   size_t n;

   std::cin >> n;

   std::ofstream("date.out") << fn(n);

}