fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(NULL);
  7.  
  8. long long n;
  9. cin >> n;
  10. long long ans = (n - 1) * n * (n + 1) / 3;
  11.  
  12. cout << ans << "\n";
  13.  
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5324KB
stdin
3
stdout
8