---
title: "Alternating Sum Invariant on a Row of Perfect Squares"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-olympiad-nt-w1-invariants-alternating-row-sum"
board: "Olympiad"
grade: "Olympiad"
published_at: "2026-11-28T15:30:00+05:30"
---

# Alternating Sum Invariant on a Row of Perfect Squares

The $10$ integers $(a_1, a_2, \dots, a_{10}) = (1^2, 2^2, 3^2, \dots, 10^2)$ are written in a row. In one move, you may either:
1. Choose two adjacent entries $a_i$ and $a_{i+1}$ ($1 \le i \le 9$) and add the same integer $k$ to both, or
2. Choose two entries separated by one position, $a_i$ and $a_{i+2}$ ($1 \le i \le 8$), and swap them.

After a sequence of moves, the last nine entries $a_2, a_3, \dots, a_{10}$ are all equal to $200$, and the first entry is $a_1 = x$. Find $x$.

## Textbook Solution

Consider the alternating sum
$$S = \sum_{j=1}^{10} (-1)^j a_j = -a_1 + a_2 - a_3 + a_4 - \dots - a_9 + a_{10}.$$
Check how each allowed move affects $S$:
1. Adding $k$ to adjacent entries $a_i$ and $a_{i+1}$ changes $S$ by $(-1)^i k + (-1)^{i+1} k = 0$.
2. Swapping $a_i$ and $a_{i+2}$ moves both numbers between positions of the *same* parity ($i \equiv i+2 \pmod 2$), so their signs in $S$ do not change, leaving $S$ unchanged.

Hence $S$ is an **invariant** of the process.
Compute the initial value of $S$:
$$S_{\text{init}} = (2^2 - 1^2) + (4^2 - 3^2) + (6^2 - 5^2) + (8^2 - 7^2) + (10^2 - 9^2)$$
$$= (2+1)(2-1) + (4+3)(4-3) + \dots + (10+9)(10-9) = 1 + 2 + 3 + \dots + 10 = 55.$$
Compute the final value of $S$ for $(x, 200, 200, \dots, 200)$:
$$S_{\text{final}} = -x + \underbrace{(200 - 200) + \dots + (200 - 200)}_{4 \text{ pairs}} + 200 = 200 - x.$$
Equating $S_{\text{final}} = S_{\text{init}}$:
$$200 - x = 55 \implies x = 145.$$

## Vedic Shortcut

Spot two shortcuts at once:
1. **Alternating Sum Invariant**: Adjacent $+k$ cancels in $(-1)^j a_j$, and distance-$2$ swaps preserve position parity, so $S = \sum (-1)^j a_j$ is constant.
2. **Triangular Sum of Alternating Squares**: $2^2 - 1^2 + 4^2 - 3^2 + \dots + (2n)^2 - (2n-1)^2 = 1 + 2 + \dots + 2n = n(2n+1)$, which for $2n = 10$ is immediately $T_{10} = 55$.
Then $-x + 200 = 55 \implies x =$ **$145$**.

## Common Mistakes

- **Using the ordinary sum $\sum a_j$**: Adding $k$ to two adjacent numbers changes the ordinary sum by $2k$, so the ordinary sum is not invariant.
- **Sign error at the tail**: Pairing $a_2 - a_3 + \dots - a_9 + a_{10}$ gives four cancelling pairs $(a_2-a_3), \dots, (a_8-a_9)$ plus $+a_{10}$, not $0$! Forgetting $+a_{10}$ gives $-x = 55 \implies x = -55$.