4. A national football association stipulates: In the league, a team gets $a$ points for a win, $b$ points for a draw, and 0 points for a loss, where real numbers $a>b>0$. If a team has exactly 2015 possible total scores after $n$ matches, find the minimum value of $n$.
4. Suppose a team wins $x$ games, draws $y$ games, and loses $z$ games in $n$ matches, where $x, y, z \in \mathbf{N}$, and $x+y+z=n$. Then, the total score of the team after $n$ matches is $a x + b y (0 \leqslant x + y \leqslant n)$.

Therefore, to consider the number of possible total scores the team can achieve after $n$ matches, we only need to consider the number of possible values for $a x + b y$.
(1) If $\frac{a}{b} \in \mathbf{R} \backslash \mathbf{Q}$, then
$$
a x + b y = a x^{\prime} + b y^{\prime} \Leftrightarrow x = x^{\prime}, y = y^{\prime}
$$
(If $x \neq x^{\prime}, y \neq y^{\prime}$, then
$$
a(x - x^{\prime}) = b(y^{\prime} - y) \Leftrightarrow \frac{a}{b} = \frac{y^{\prime} - y}{x - x^{\prime}},
$$

which is a contradiction).
When $x = 0$, $y = 0, 1, \cdots, n$, at this time, $a x + b y$ has $n + 1$ possible values;

When $x = 1$, $y = 0, 1, \cdots, n - 1$, at this time, $a x + b y$ has $n$ possible values;

And so on, when $x = n$, $y = 0$, at this time, $a x + b y$ has 1 possible value.

Therefore, when $\frac{a}{b} \in \mathbf{R} \backslash \mathbf{Q}$, the total score of the team after $n$ matches has
$$
\sum_{i=1}^{n+1} i = \frac{1}{2}(n+1)(n+2)
$$

possible values (similar to the number of arrangements of $n$ balls and 2 barriers, when $0 \leqslant x + y \leqslant n$, $a x + b y$ has $\mathrm{C}_{n+2}^{2} = \frac{1}{2}(n+1)(n+2)$ possible values).
$$
\text{Let } \frac{1}{2}(n+1)(n+2) = 2015 \text{. Clearly, } n \text{ has no}
$$

positive integer solutions.
$$
\text{(2) If } \frac{a}{b} \in \mathbf{Q} \text{, let } \frac{a}{b} = \frac{A}{B} \left(A, B \in \mathbf{Z}_{+}, \right. \text{ }
$$
$(A, B) = 1$, and $A > B > 0)$, then the problem is equivalent to considering the number of possible values for $A x + B y$.
(i) When $n \geq 1$, i.e.,
$$
A^2 + 3A - 4030 \leq 0,
$$

we get $1 < A \leq 62$.
Since $4030 = 2 \times 5 \times 13 \times 31$, we have $A = 2, 5, 10, 13, 26, 31, 62$.
When $A = 2$, $n = 1007$;
When $A = 5$, $n = 404$;
When $A = 10$, $n = 205$;
When $A = 13$, $n = 160$;
When $A = 26$, $n = 89$;
When $A = 31$, $n = 79$;
When $A = 62$, $n = 62$.
In summary, the minimum value of $n$ is 62, corresponding to $A = 62$.