SPOJ ABCDEF - Binary Search Problem - WA (SOLVED)

Getting WA, Where am i wrong? Here’s the problem and code:

Problem: https://www.spoj.com/problems/ABCDEF/
Code: https://ide.codingblocks.com/s/76324/

Code:

signed main(){
    FASTER;
    int n;cin>>n;
    vi v(n),abc,fed;cin>>v;
    for(int a=0;a<n;a++){
        for(int b=0;b<n;b++){
            for(int c=0;c<n;c++){
                abc.push_back(v[a]*v[b]+v[c]);
            }
        }
    }
    for(int f=0;f<n;f++){
        for(int e=0;e<n;e++){
            for(int d=0;d<n && v[d]!=0;d++){//BREAKS THE LOOP! DONT BREAK IT, JUST SKIP THAT VALUE
                fed.push_back(v[d]*(v[f]+v[e]));
            }
        }
    }
    sort(all(fed));
    int cnt=0;
    for(int s1:abc)cnt+=(upper_bound(all(fed),s1)-lower_bound(all(fed),s1));
    cout<<cnt;
}

Thanks!