I suggest the following approach for the revised question:
1) Put the list of integers into a 1D array (array1)
2) Get $N$ from the amount of elements in the array.
3) Calculate all non-unique possible values of $F(i,j)$ using array1, and put these into a 1D array (array2).
4) Using array2, derive unique value of $F(i,j)$, and put them into a 1D array (array3).
5) Using array3 and array2, calculate the frequency for each unique $F(i,j)$, and put unique $F(i,j)$ and its frequency into a 2D array (array4).
6) Review contents of array4 to pick up any patterns that can be coded for - to help with the next step.
Eg For unique $F(i,j)$ with value of $1$, these all have a GCD of $1$ with all other $F(i,j)$ so counting them is easier.
7) Start with counttuples=0. Work out and add countuples for every occurence of $F(i,j)=1$ with another $F(i,j)$
8) For each occurence of $F(i,j)>1$, calculate GCD of that with every other $F(i,j)>1$ using the frequencies. If the GCD=1, then the values are coprime, so increment counttuples by 1.
Note: further efficiencies could be made to step 8) using concepts from number theory.
9) After step 8) is done, show what value of counttuples is to the user
Example - VBA code in: https://stackoverflow.com/questions/41852006/excel-vba-how-to-make-code-more-efficient-and-take-less-time