Problem: For each integer $n\geq3$ , let $f(n)$ be the number of $3$ -element subsets of the vertices of the regular $n$ -gon that are the vertices of an isosceles triangle (including equilateral triangles). Find the sum of all values of $n$ such that $f(n+1)=f(n)+78$

Solution: We first notice that when a polygon has $s$ sides where $s\not\equiv 0\pmod{3}$ , there cannot exist any three vertices that form an equilateral triangle. Also, the parity of $s$ and $s+1$ also matters, since they influence how many isosceles triangles including equilateral triangles exist in the polygon. We can model an equation $2x+y=s$ , where the lines that are congruent connect the vertices that are $x$ vertices apart and the other line has vertices that are $y$ vertices apart. If $s$ is even, there are $\frac{s-2}{2}$ solutions for $(x,y)$ which would create a unique type of isosceles triangle. We subtract two since $y$ cannot be zero. If $s$ is odd, there are $\frac{s-1}{2}$ solutions for $(x,y)$ .
Next, we do casework on the congruence of $s\pmod{3}$ and the parody of $s$ using the information above:
Case 1:
$s\not\equiv 0\pmod{3}$ $s+1\not\equiv 0\pmod{3}$
$s$ is even, $s+1$ is odd
There are $\frac{s-2}{2}$ unique types of isosceles triangles in the polygon with $s$ sides. Each isosceles triangle has a unique point which connects the two congruent sides. Therefore, for each type of isosceles triangle, there exists $s$ of those triangles since the unique point can be any of the $s$ vertices. There are $\frac{s}{2}$ types of isosceles triangles in the polygon with $s+1$ sides and $s+1$ unique points for each type of triangle. Therefore, $\frac{s}{2}\cdot{(s+1)}-\frac{s-2}{2}\cdot{(s)}=78$ . Solving, we get $s=52$
Case 2:
$s\not\equiv 0\pmod{3}$ $s+1\not\equiv 0\pmod{3}$
$s$ is odd, $s+1$ is even
Using similar logic, there are $\frac{s-1}{2}\cdot{(s)}$ possible isosceles triangles in the $s$ sided polygon. There are $\frac{s-1}{2}\cdot{(s+1)}$ possible isosceles triangles in the $s+1$ sided polygon. The difference should be $78$ , so $\frac{s-1}{2}\cdot{(s+1)}-\frac{s-1}{2}\cdot{(s)}=78$ . Solving gives $s=157$
For both of these cases, we don't have to worry about equilateral triangles since in both cases $s,s+1\nmid3$
Case 3:
$s\not\equiv 0\pmod{3}$ $s+1\equiv 0\pmod{3}$
$s$ is even, $s+1$ is odd
There are $\frac{s-2}{2}\cdot{(s)}$ possible isosceles triangles in the $s$ sided polygon. The $s+1$ case is a bit more complicated, as we have to consider equilateral triangles as well. In this case, there is one solution where $x=y$ , which would produce an equilateral triangle. Therefore, we subtract that case to calculate only isosceles triangles with 2 congruent sides. Only isosceles triangles with exactly 2 congruent sides have a unique point, while there exist only $\frac{s+1}{3}$ distinct equilateral triangles in a polygon with $s+1$ sides, the rest are equivalent and symmetrical. Therefore, there are $(\frac{s}{2}-1)\cdot{(s+1)}+\frac{s+1}{3}$ isosceles triangles with at least 2 congruent sides in a polygon with $s+1$ sides. Putting it together, $\frac{s}{2}-1\cdot{(s+1)}+(\frac{s+1}{3})-\frac{s-2}{2}\cdot{(s)}=78$ . Solving yields $5s=772$ which is impossible since $s$ has to be an integer. Therefore, this case is not valid.
Case 4:
$s\not\equiv 0\pmod{3}$ $s+1\equiv 0\pmod{3}$
$s$ is odd, $s+1$ is even
There are $\frac{s-1}{2}\cdot{(s)}$ isosceles triangles in the $s$ sided polygon. Using the idea above, there are $(\frac{s-1}{2}-1)\cdot{(s+1)}$ isosceles triangles with 2 congruent sides in an $s+1$ sided polygon. There are $\frac{s+1}{3}$ equilateral triangles. Therefore, $(\frac{s-1}{2}-1)\cdot{(s+1)}+(\frac{s+1}{3})-\frac{s-1}{2}\cdot{(s)}=78$ . Looking at the left hand side, it is clear that $s$ has to be negative, which is not valid. Therefore, this case is not valid.
Case 5:
$s\equiv 0\pmod{3}$ $s+1\not\equiv 0\pmod{3}$
$s$ is even, $s+1$ is odd
There are a total of $(\frac{s-2}{2}-1)\cdot{(s)}+(\frac{s}{3})$ isosceles triangles in a polygon with $s$ sides. There are a total of $\frac{s}{2}\cdot{(s+1)}$ isosceles triangles in a polygon with $s+1$ sides. Therefore, $\frac{s}{2}\cdot{(s+1)}-(\frac{s-2}{2}-1)\cdot{(s)}-(\frac{s}{3})=78$ . Simplifying, we get $s=36$
Case 6:
$s\equiv 0\pmod{3}$ $s+1\not\equiv 0\pmod{3}$
$s$ is odd, $s+1$ is even
There are a total of $(\frac{s-1}{2}-1)\cdot{(s)}+(\frac{s}{3})$ isosceles triangles in the polygon with $s$ sides. There are $\frac{s-1}{2}\cdot{(s+1)}$ isosceles triangles in the polygon with $s+1$ sides. Therefore, $\frac{s-1}{2}\cdot{(s+1)}-(\frac{s-1}{2}-1)\cdot{(s)}-(\frac{s}{3})=78$ . Simplifying, we get $7s=471$ , which means $s$ is not an integer. Thus, this case is invalid.
Adding all the valid cases, we obtain $52+157+36=\boxed{245}$

Answer:  245