#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

struct Rat {
	int x, y;
	Rat() : x(0), y(1) {}
	Rat(int x, int y): x(x), y(y) {}
	bool operator<(const Rat& rhs) const { return LL(x)*rhs.y < LL(rhs.x)*y; }
};

class BearDarts { public:
	long long count(vector <int> w)
	{
		map<Rat, int> r;
		for(int c=1; c<w.size(); ++c)
		for(int d=c+1; d<w.size(); ++d)
			r[Rat(w[d], w[c])]++;

		LL cnt = 0;
		for(int b=1; b<w.size(); ++b) {
			for(int c=b,d=c+1; d<w.size(); ++d)
				r[Rat(w[d], w[c])]--;
			for(int a=0; a<b; ++a)
				cnt += r[Rat(w[a],w[b])];
		}
		return cnt;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const long long& Expected, const long long& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, BearDarts().count(w));}
int main(){

CASE(0)
	int w_[] = {6,8,4,3,6};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = 2LL; 
END
CASE(1)
	int w_[] = {3,4,12,1};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = 0LL; 
END
CASE(2)
	int w_[] = {42,1000000,1000000,42,1000000,1000000};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = 3LL; 
END
CASE(3)
	int w_[] = {1,1,1,1,1};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = 5LL; 
END
CASE(4)
	int w_[] = {1,2,3,4,5,6,5,4,3,2,1};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = 22LL; 
END
CASE(5)
	int w_[] = {33554432, 33554432, 67108864, 134217728};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = 0LL; 
END
CASE(6)
	int w_[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = -1LL; 
END
CASE(7)
	int w_[] = {630658131,674846157,452250605,72688214,501784734,933449113,82196239,31414971,211283393,264325337,616901840,736142233,589307470,181160610,338886067,100343237,255830472,621917322,971834762,307020630,600621417,199155197,703724521,128060397,966810889,382874528,475817222,46530806,959498879,579903637,771169904,245378166,352031021,992869674,342570301,626617379,731419930,581139819,992816954,580260640,108008588,430460885,51132293,32034089,482484376,175676159,542863113,849086039,977322697,136149730,853538450,199291560,249351359,724849011,902366087,732345206,163969863,322548316,446425183,881461769,746864428,68615261,126874635,333035622,440876501,17243141,2340920,97492945,716562055,472619840,363979956,471185034,406081686,515741140,756275946,714549197,338556500,194547087,546610208,257675870,33710256,802065638,204950188,303218433,885772243,290175977,848920914,881525880,958057777,948718218,598802162,636890603,230076679,373777525,28910253,172484093,643733354,364742759,274057562,183117033,467009419,974545501,959926363,538458476,556333781,601179165,171910885,621879366,398519370,374792375,508024811,539000578,61054784,887279975,460022567,440268935,47552409,382479871,69906179,411476741,796399094,965733870,308629944,761243770,70261760,843348773,403692055,700030656,606266420,100178381,303127498,206249775,550805123,917798443,826702247,485347530,840990879,150033025,171565660,170101729,764884444,784863925,75296424,638113913,95334703,825009734,721191787,308025814,689325487,448539742,223485496,471854055,472523684,645956221,614227092,420724928,666424122,530474957,589926993,404330168,185192729,918621048,582373065,328708386,708387950,74076025,607799602,439562466,432865412,610676841,535195990,585427457,246420336,8809494,809712544,31194496,559805731,188059703,683192618,818912707,111662405,248839112,346795906,629038738,476017440,690761367,355659055,593000653,654547467,537644675,891161492,745712919,437580781,705745062,508964249,687227730,812929370,267312194,705155393,7711760,127572087,971605815,44280715,378735865,390479356,321792558,752933606,410784082,604083919,679019619,826716548,694764889,807637217,804152717,833640045,631838489,231301090,381655231,264199244,462860067,165307601,458604996,655857591,160655773,601340462,89339333,694309694,351290759,910800630,768706484,767624728,470421348,761329322,765466253,401930953,765162609,800726919,195977584,534664087,842279353,273338038,384043435,193857017,178902314,512928089,72434125,116621193,456147827,348796512,726266151,515508971,717622153,845739365,775000354,372633255,545123141,620427628,365173668,246002420,520085050,120297174,882252882,963172787,112776793,371987711,808073031,418593199,203509329,336807305,690734519,767120401,370137337,699065668,989609189,838336362,418581997,211840300,550132168,814230186,614451783,593764029,481538722,273027119,782481100,21893089,731577635,165939178,812289426,569027468,572983810,36211526,7828665,144468427,525018320,954818656,250945739,544757127,984168950,579491237,349833320,468093150,553640876,161396731,53899008,754005702,595206878,655954962,848935583,257277572,688753799,255281723,879610727,405245259,771841022,302442893,10812735,865324410,554325521,650899852,774302059,663681633,381997319,435704664,766411547,369529901,694226593,777690563,751347319,924154325,605236416,453959749,866526801,410412846,757444956,594381888,800632836,498294059,407278528,257369206,217953403,552162001,406330592,214994959,220655113,236023011,554480049,228935706,717396416,640155255,137519327,521221947,449033479,980942467,503687084,572819779,991969453,171469377,751035721,979934809,429115995,80824876,132219782,902094720,617217135,413914611,965530169,351785431,789138428,994114976,22329146,768159390,894135261,456742513,292224195,871544665,879059603,670614419,313467844,891812868,238907479,736042754,834616478,220522417,205578615,422985628,271151349,927095118,570499416,290819638,592168696,780449915,519268534,411058342,491896448,751396259,670873734,955310424,369903235,348973963,3936442,800818767,637237968,613321574,186490949,360963584,194620788,928359101,108953135,583416816,813850972,745711169,141202445,853204015,148131533,785428082,84903050,961332162,604372337,57685999,104644263,486064127,572788557,436884210,2825347,16648120,152299348,937045772,913412143,974683212,558778609,14855935,841574226,475000923,316458023,760713680,718461849,44574359,811402667,578915668,847891414,528197290,372459263,450943047,604636474,594252610,282561901,485842067,770118261,236508779,234250390,370278239,28497073,743383797,107501085,396504963,917971041,85636446,203355851,494052129,760720919,767324517,965898545,326918469,350217327,276500835,197667355,928308874,284444392,692130049,63386659,22150464,210715944,82478013,59782091,651933038,346123038,634841262,19908209,925887024,492105558,744650376,69674937,384374272,190375075,452549208,441723553,181507612,625949254,857117487,986296268,906540787,186041812,463285718,847057129,364994501,6958365,553304478,981984908,240251437,971068110,171102545,142496689,79982902,921984482,354051456,769429030,820023075,218848043,938800629,570063320,315682658,755961553,882078135,836660706,126239015,264574692,270487168,778416180,840341403,400676084,226249423,254674312,747739067,577787569,471791319,469541180,723205605,525543101,467973392,676164572,342582574,814591307,160132681,291067573,881124101,651566549,969303078,645921440,200654765,952681421,645473189,942603369,191301249,388205848,277942815,344133749,766861188,597819508,704323647,967267875,794895400,157285571,838973202,469349839,522834793,702611421,133641436,658943451,644678218,555768826,451099506,406226052,261376886,573154890,977855516,689285433,82595532,117258803,13820904,12214871,96575754,212311227,990129176,58377984,590973865,257452881,919185916,781544118,417576179,38560049,332938531,765892659,987308040,314212776,459614127,854489525,345466867,860572089,85332592,685245846,931314156,616427446,391037031,566474389,512737410,602559206,195465626,401318675,603709277,798514876,259742047,243668739,398331835,969346879,401604887,43808765,968434520,797117107,49410806,44809540,754077409,968281211,241362547,775645004,761216743,923627672,978887450,493604463,720598752,487329652,576882340,168313220,687829342,448733235,799588976,475227992,431655668,611216592,163916563,463871396,570492989,888271719,482714708,537981031,896443716,935942199,34682629,320978415,73905161,474935938,4795747,517081840,856084186,248456956,673700364,713396366,682137378,980441995,488986272,636013411,243147520,872802395,425078239,145611722,273513636,218654467,211930899,145816180,66494308,720393188,518196800,136416935,679314552,925249261,393765240,622070385,36059480,270174040,213240851,544853335,624483332,545954793,545977618,74608853,192180769,831021309,143526863,969410705,431964418,524607098,605779870,248209216,202984123,660878223,603479853,743191951,689184569,92213874,715407727,562358862,320660865,441641657,769644651,695744823,399360527,526494669,711186515,749818648,394269861,652642141,93481827,539973252,554431882,487208779,330242739,193797550,63638002,286898560,747913685,888037961,404785357,520679578,893497969,833799848,407588985,851979260,212133643,896569860,47219687,455471592,949480176,216329786,580291175,444621391,488686768,986270998,530063108,249790062,794207258,579673238,598957240,286521707,17296530,785223607,472409208,531240730,292343697,92958342,86909636,811016722,437531232,898354311,297797367,410360331,775625567,532598973,861097416,490755544,516630989,736306406,587987988,521230573,848069807,813707388,342469097,926628210,61533101,522516693,812984869,47337698,633405933,76806180,832928012,501285560,338887804,188417546,225193354,213280170,357821908,528091989,586931563,480949464,541633695,648677174,603873002,892847752,26692158,423463263,25650201,586450796,539013052,357756123,242140472,638585408,669816184,941283499,262916236,507070900,451020902,17246603,5139495,443718227,98615819,921454994,730119764,277402559,534035699,584915641,167272467,982149300,160325650,913673558,437969395,629837218,82258081,48352519,590012854,922392701,647393988,598880007,929571797,229453839,174533431,839555589,203626893,378447172,207121125,253141830,955751342,233334173,61191990,279222954,363920932,317507426,713157897,182289378,731548929,659822347,765897028,77244198,847744646,639015109,539679877,477313863,51033563,119125278,569280688,59264156,431925224,448855253,930103852,817231252,916839297,567688185,666671186,972767491,101399698,413227984,443393009,433447656,66143747,471857146,429230087,141955580,521933259,380704049,11853488,594733301,923172319,954716099,709791992,556974795,203176064,322337403,605578269,616046343,423534957,288269005,332248518,454374541,219543600,493541451,411228854,511089158,847323583,330236214,292870938,391614999,656753186,98952228,32621944,950050401,279285746,708917783,689531891,410459402,534091538,721995763,534018567,432116494,155979455,354306670,960554891,647570721,910777621,299982927,755366088,148233390,684314106,166537361,803933329,805634586,793987010,605856389,697895819,145645374,173906608,536749891,527090890,478509862,506614023,256864199,166444512,35629523,441581276,590774102,511249006,922997171,630360994,569632349,527581244,291263600,558719798,726366197,499076100,417767851,262240325,257943242,632452328,77556554,313346260,527716988,696795213,315800187,991754183,249131259,91243326,986916071,975588428,85958445,996650195,498124238,434926824,767453776,77199364,22824949,319625686,585313001,261296467,246854842,622884223,576783008,554902077,25927055,574693424,699785404,251453202,828549805,591055210,844910484,883923896,150172832,659410790,177819215,107784424,192994949,696398067,70703919,803874680,678806252,30058577,890094661,347949677,714278835,274132394,654861439,952254816,67174280,322471831,44213643,99685560,69659457,931818504,525894474,128148962,568578114,406404080,595090144,359404862,970081526,596453854,274908050,653357490,991098958,512019990,788928617,461691871,400848987,423468412,128598898};
	  vector <int> w(w_, w_+sizeof(w_)/sizeof(*w_)); 
	long long _ = -1LL; 
END
}
// END CUT HERE
