Good explanation.
I think there is a minor typo, and correct me if I am wrong,
for this line:
for all j < i, f[i][A[i] - A[j]] += f[j][A[i] - A[j]],
it means that only when there is an arithmetic subsequence ending at A[j], then we could add that count to the new subsequence ending at A[i]. But it misses the case when the subsequence ending at A[j] is a weak one.