// sum for k=1..n of {k*(k+1) if it does not divide by 7}
// example of how it looks in a more functional language, D (http://dlang.org)
module sumseq;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	stdin  = File ("sumseq.in",  "rt");
	stdout = File ("sumseq.out", "wt");
	auto n = readln.strip.to !(int);
	iota (1, n + 1)
	    .map !(x => x * (x + 1))
	    .filter !(x => x % 7 != 0)
	    .fold !((x, y) => x + y) (0L) // sum (0L)
	    .writeln;
}
