Let a1=a2=1, a3=a4=3, a5=⋯=a12=0.
It is easy to check that any 9 integers of them will not meet the requirement. So n≥13. We will prove that n=13.
We only need to prove the following statement:
Given a group of m integers a1,a2,…,am, if there are not three ai1,ai2,ai3 in them and b1,b2,b3∈{4,7} such that b1ai1+b2ai2+b3ai3≡0(mod9), then either m≤6 or 7≤m≤8 and there are ai1,ai2,…,ai6 in a1,a2,…,am and b1,b2,…,b6∈{4,7} such that 9∣b1ai1+b2ai2+⋯+b6ai6.
We define
A1={i∣1≤i≤m,9∣ai},
A2={i∣1≤i≤m,ai≡3(mod9)},
A3={i∣1≤i≤m,ai≡6(mod9)},
A4={i∣1≤i≤m,ai≡1(mod3)},
A5={i∣1≤i≤m,ai≡2(mod3)}.
Then ∣A1∣+∣A2∣+∣A3∣+∣A4∣+∣A5∣=m and
(1) if i∈A2,j∈A3 then 9∣4ai+4aj;
(2) if i∈A4,j∈A5 then one of 4ai+4aj,4ai+7aj and 7ai+4aj is a multiple of 9 as all of them are divisible by 3 and they are distinct according to mod 9;
(3) if either i,j,k∈A2 or i,j,k∈A3 then 9∣4ai+4aj+4ak;
(4) if either i,j,k∈A4 or i,j,k∈A5 then one of 4ai+4aj+4ak,4ai+4aj+7ak and 4ai+7aj+7ak is a multiple of 9 as all of them are divisible by 3 and they are distinctive according to mod 9.
By the assumption, we have ∣Ai∣≤2 (1≤i≤5).
If ∣A1∣≥1, then ∣A2∣+∣A3∣≤2, ∣A4∣+∣A5∣≤2. Hence
m=∣A1∣+∣A2∣+∣A3∣+∣A4∣+∣A5∣≤6.
Now assume ∣A1∣=0 and m≥7. Then
7≤m=∣A1∣+∣A2∣+∣A3∣+∣A4∣+∣A5∣≤8.
Further,
min{∣A2∣,∣A3∣}+min{∣A4∣,∣A5∣}≥3.
From (1) and (2) we know there exist i1,i2,…,i6∈A2∪A3∪A4∪A5 (i1<i2<⋯<i6) and b1,b2,…,b6∈{4,7} such that 9∣b1ai1+b2ai2+⋯+b6ai6.
The proof of statement is complete.
Now, when n≥13 it is easy to verify with the statement, for any group of integers a1,a2,…,an, there always exist ai1,ai2,…,ai9 (1≤i1<i2<⋯<i9≤n) and bi∈{4,7} (i=1,2,…,9) such that b1ai1+b2ai2+⋯+b9ai9 is a multiple of 9. That completes the proof.