#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef float ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 48;
	const ld M1 = 1e9;
	const int C2 = C1;
	const ld M2 = 40;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 42;
	const int M1 = 20200;
	const int C2 = 42;
	const int M2 = 200200;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 42;
	const int M1 = 200200;
	const int C2 = 42;
	const int M2 = 200200;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline ld calc(ld x) {
	ld ans = 0;
	ld minv = 0, maxv = 0;
	fore(i, 1, n + 1) {
		ld val = s[i] - i * x;
		ans = max(ans, abs(val - minv));
		ans = max(ans, abs(val - maxv));
		minv = min(minv, val);
		maxv = max(maxv, val);
	}
	return ans;
}

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];

	ld lf = -1e13, rg = 1e13;
	forn(i, 200) {
		ld lmid = lf + (rg - lf) / 2.1;
		ld rmid = rg - (rg - lf) / 2.1;
		ld lval = calc(lmid);
		ld rval = calc(rmid);
		if (lval < rval) rg = rmid;
		else lf = lmid;
	}

	cout << calc((lf + rg) / 2) << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 39;
	const int M1 = 20200;
	const int C2 = 40;
	const int M2 = 20200;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 57;
	const ld M1 = 4e9;
	const int C2 = 57;
	const ld M2 = 4e9;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	ld lf = 0, rg = 10200;
	forn(i, 43) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -10200, rr = 10200;
		forn(j, 43) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -10200, rr = 10200;
		forn(j, 43) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 50;
	const int M1 = 200200;
	const int C2 = 50;
	const int M2 = 200200;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C2 = 40;

	ld lf = 0, rg = 10200;
	forn(i, 35) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -20200, rr = 20200;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -20200, rr = 20200;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	ld lf = 0, rg = 10200;
	forn(i, 35) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -10200, rr = 10200;
		forn(j, 37) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -10200, rr = 10200;
		forn(j, 37) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef float ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 42;
	const ld M1 = 1e6;
	const int C2 = C1;
	const ld M2 = M1;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#undef NDEBUG
#ifdef SU1
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef float ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-11, PI = 3.1415926535897932384626433832795;

const int N = 200200;

int n, a[N];

inline bool read() {
	if (!(cin >> n)) return false;
	forn(i, n) assert(scanf("%d", &a[i]) == 1);
	return true;
}

li s[N];

inline void solve() {
	forn(i, n) s[i + 1] = s[i] + a[i];
	//cerr << s[n - 1] << ' ' << s[n] << endl;

	const int C1 = 42;
	const ld M1 = 5e6;
	const int C2 = C1;
	const ld M2 = M1;

	ld lf = 0, rg = M1;
	forn(i, C1) {
		ld delta = (lf + rg) / 2;

		//delta = 0;

		ld ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;

			//epsilon = 2;

			ld minv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - minv + EPS >= delta) {
					//cerr << "k=" << k << " cur=" << cur << " maxv=" << maxv << endl;
					good = 1;
					break;
				}
				minv = min(minv, cur);
			}
			//cerr << "bad=" << bad << endl;
			//exit(0);

			if (good) ll = epsilon;
			else rr = epsilon;
		}
		ld x1 = ll;

		//cerr << "x1=" << x1 << endl;
		//exit(0);

		ll = -M2, rr = M2;
		forn(j, C2) {
			ld epsilon = (ll + rr) / 2;
			ld maxv = 0;
			int good = 0;
			fore(k, 1, n + 1) {
				ld cur = s[k] - epsilon * k;
				if (cur - maxv <= -delta + EPS) {
					good = 1;
					break;
				}
				maxv = max(maxv, cur);
			}
			if (good) rr = epsilon;
			else ll = epsilon;
		}
		ld x2 = rr;
		//cerr << "x1=" << x1 << " x2=" << x2 << endl;
		if (x1 <= x2 + EPS) rg = delta;
		else lf = delta;
	}
	cout << rg << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		solve();
		//break;
	}

    return 0;
}


#include<iostream>

#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<climits>
#include <bits/stdc++.h>
#include<bitset>
using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define MOD 1000000007

struct node {
    long long b;
    int i, t;

    node(long long b, int i, int t) {
        this->b = b;
        this->i = i;
        this->t = t;
    }
};

vector<node> nds;
int lft[2000001], rt[2000001];

bool operator < (const node& n1, const node& n2) {
    if (n1.b < n2.b) return true;
    else if (n1.b > n2.b) return false;

    if (n1.i < n2.i) return true;
    else if (n1.i > n2.i) return false;

    return (n1.t < n2.t);
}

long long solve(int st, int end, int n) {
    for (int i = st; i <= end; i++) {
        int indx = i-st;
        lft[indx] = i != st ? lft[indx-1] : 0ll;

        if (nds[i].t == 0) lft[indx] ++;
    }

    for (int i = end; i >= st; i--) {
        int indx = i-st;
        rt[indx] = (i != end) ? rt[indx+1] : 0ll;

        if (nds[i].t == 2) rt[indx] ++;
    }

    //for (int i = st; i <= end; i++)
        //cout << nds[i].b << " " << nds[i].i << " " << nds[i].t << endl;
    //cout << "================" << endl;

    bool flags[n][3];
    for (int i = 0; i < n; i++) flags[i][0] = flags[i][1] = flags[i][2] = 0;

    for (int i = st; i <= end; i++) flags[nds[i].i][nds[i].t] = true;

    long long res = 0;
    for (int i = st; i <= end; i++) {
        if (nds[i].t != 1) continue;

        long long x = lft[i-st], y = rt[i-st];

        //cout << "-> " << x << " " << y << endl;
        if (flags[nds[i].i][0]) x --;
        if (flags[nds[i].i][2]) y --;

        res += (x*y);
    }

    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int T = 1;
    //cin >> T;

    while (T--) {
        long long n, k;
        cin >> n >> k;

        long long a[n];
        for (int i = 0; i < n; i++) cin >> a[i];

        for (int i = 0; i < n; i++) {
            nds.push_back(node(a[i], i, 0));
            if (a[i]%k == 0) nds.push_back(node(a[i]/k, i, 1));
            if (a[i]%(k*k) == 0) nds.push_back(node(a[i]/(k*k), i, 2));
        }

        sort(nds.begin(), nds.end());

        int j = 0;
        long long res = 0ll;
        while (j < nds.size()) {
            int k = j;

            while (nds[k].b == nds[j].b) {
                k ++;
            }

            k --;

            res += solve(j, k, n);

            j = k+1;
        }

        cout << res << endl;

    }

    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
using namespace std;
ll n,m,k,x,y,p,q;
const int MAX = 2e5+1;
int a[MAX];
unordered_map<int, vi>M;

void each_case()
{
    M.clear();
    rep(i,n)
        cin>>a[i], M[a[i]].pb(i);
    x=0;
    int l,r;
    bool done = false;
    rep(i,n)
    {
        // pv(a[i]);
        l = r = 0;
        if(a[i] == 1 and k == 1)
        {
            if(done == false)
            {
                ll fr = sz(M[a[i]]);
                x += (fr*(fr-1)*(fr-2))/6ll;
                // pv(x);
                done = true;
            }
            continue;
        }
        p = a[i]/k;
        if(p*k != a[i])
            continue;
        if(sz(M[p]))
        {
            // pv(p);
            // rep(j,sz(M[p]))
            //     cout<<M[p][j]<<" ";nl;
            auto pp = lower_bound(all(M[p]), i);
            int ind = pp - M[p].begin();
            l = max(ind - (ind == 0 and i <= M[p][0]), 0);
            // pv(l);
            // cout<<"less than "<<i<<" found in pos "<<l<<"\n";
        }
        q = a[i]*k;
        if(sz(M[q]))
        {
            // pv(q);
            // rep(j,sz(M[q]))
            //     cout<<M[q][j]<<" ";nl;
            auto pp = upper_bound(all(M[q]), i);
            int ind = pp - M[q].begin();
            r = sz(M[q]) - ind;
        }
        x += l*r;//*sz(M[a[i]]);
        // cout<<p<<" "<<a[i]<<" "<<q,nl;
        // cout<<l<<" "<<sz(M[a[i]])<<" "<<r,nl;
        // pv(x);
    }
    cout<<x,nl;
}

int main()
{
    fast

    // test
    // {
    while(cin>>n>>k)
    {
    	each_case();
    }
    // }

    cin>>n;

    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
using namespace std;
ll n,m,k,x,y,p,q;
const int MAX = 2e5+1;
ll a[MAX];
unordered_map<ll, vi>M;

void each_case()
{
    M.clear();
    rep(i,n)
        cin>>a[i], M[a[i]].pb(i);
    x=0;
    ll l,r;
    bool done = false;
    rep(i,n)
    {
        // pv(a[i]);
        l = r = 0;
        if(a[i] == 1 and k == 1)
        {
            if(done == false)
            {
                ll fr = sz(M[a[i]]);
                x += (fr*(fr-1)*(fr-2))/6ll;
                // pv(x);
                done = true;
            }
            continue;
        }
        p = a[i]/k;
        if(p*k != a[i])
            continue;
        if(sz(M[p]))
        {
            // pv(p);
            // rep(j,sz(M[p]))
            //     cout<<M[p][j]<<" ";nl;
            auto pp = lower_bound(all(M[p]), i);
            ll ind = pp - M[p].begin();
            l = max(ind - (ind == 0 and i <= M[p][0]), 0ll);
            // pv(l);
            // cout<<"less than "<<i<<" found in pos "<<l<<"\n";
        }
        q = a[i]*k;
        if(sz(M[q]))
        {
            // pv(q);
            // rep(j,sz(M[q]))
            //     cout<<M[q][j]<<" ";nl;
            auto pp = upper_bound(all(M[q]), i);
            ll ind = pp - M[q].begin();
            r = sz(M[q]) - ind;
        }
        x += l*r;//*sz(M[a[i]]);
        // cout<<p<<" "<<a[i]<<" "<<q,nl;
        // cout<<l<<" "<<sz(M[a[i]])<<" "<<r,nl;
        // pv(x);
    }
    cout<<x,nl;
}

int main()
{
    fast

    // test
    // {
    while(cin>>n>>k)
    {
    	each_case();
    }
    // }

    cin>>n;

    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
using namespace std;
ll n,m,k,x,y,p,q;
const int MAX = 2e5+1;
ll a[MAX];
unordered_map<ll, vi>M;

void each_case()
{
    M.clear();
    rep(i,n)
        cin>>a[i], M[a[i]].pb(i);
    x=0;
    ll l,r;
    bool done = false;
    rep(i,n)
    {
        // pv(a[i]);
        l = r = 0;
        if(a[i] == 1 and k == 1)
        {
            if(done == false)
            {
                ll fr = sz(M[a[i]]);
                x += (fr*(fr-1)*(fr-2))/6ll;
                // pv(x);
                done = true;
            }
            continue;
        }
        p = a[i]/k;
        if(p*k != a[i])
            continue;
        if(sz(M[p]))
        {
            // pv(p);
            // rep(j,sz(M[p]))
            //     cout<<M[p][j]<<" ";nl;
            auto pp = lower_bound(all(M[p]), i);
            ll ind = pp - M[p].begin();
            l = max(ind - (ind == 0 and i <= M[p][0]), 0);
            // pv(l);
            // cout<<"less than "<<i<<" found in pos "<<l<<"\n";
        }
        q = a[i]*k;
        if(sz(M[q]))
        {
            // pv(q);
            // rep(j,sz(M[q]))
            //     cout<<M[q][j]<<" ";nl;
            auto pp = upper_bound(all(M[q]), i);
            ll ind = pp - M[q].begin();
            r = sz(M[q]) - ind;
        }
        x += l*r;//*sz(M[a[i]]);
        // cout<<p<<" "<<a[i]<<" "<<q,nl;
        // cout<<l<<" "<<sz(M[a[i]])<<" "<<r,nl;
        // pv(x);
    }
    cout<<x,nl;
}

int main()
{
    fast

    // test
    // {
    while(cin>>n>>k)
    {
    	each_case();
    }
    // }

    cin>>n;

    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
using namespace std;
ll n,m,k,x,y,p,q;
const int MAX = 2e5+1;
ll a[MAX];
unordered_map<ll, vi>M;

void each_case()
{
    M.clear();
    rep(i,n)
        cin>>a[i], M[a[i]].pb(i);
    x=0;
    ll l,r;
    bool done = false;
    rep(i,n)
    {
        l = r = 0;
        if(a[i] == 1 and k == 1)
        {
            if(done == false)
            {
                ll fr = sz(M[a[i]]);
                x += (fr*(fr-1)*(fr-2))/6ll;
                done = true;
            }
            continue;
        }
        p = a[i]/k;
        if(p*k != a[i])
            continue;
        if(sz(M[p]))
        {
            auto pp = lower_bound(all(M[p]), i);
            ll ind = pp - M[p].begin();
            l = max(ind - (ind == 0 and i <= M[p][0]), 0ll);
        }
        q = a[i]*k;
        if(sz(M[q]))
        {
            auto pp = upper_bound(all(M[q]), i);
            ll ind = pp - M[q].begin();
            r = sz(M[q]) - ind;
        }
        x += l*r;
    }
    cout<<x,nl;
}

int main()
{
    fast
    while(cin>>n>>k)
    {
    	each_case();
    }
    cin>>n;
    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
using namespace std;
ll n,m,k,x,y,p,q;
const int MAX = 2e5+1;
int a[MAX];
unordered_map<int, vi>M;

void each_case()
{
    M.clear();
    cin>>n>>k;
    rep(i,n)
        cin>>a[i], M[a[i]].pb(i);
    x=0;
    int l,r;
    bool done = false;
    rep(i,n)
    {
        // pv(a[i]);
        l = r = 0;
        if(a[i] == 1)
        {
            if( done == false)
            {
                ll fr = sz(M[a[i]]);
                x += (fr*(fr-1)*(fr-2))/6ll;
                // pv(x);
                done = true;
            }
            continue;
        }
        p = a[i]/k;
        if(sz(M[p]))
        {
            // pv(p);
            // rep(j,sz(M[p]))
            //     cout<<M[p][j]<<" ";nl;
            auto pp = lower_bound(all(M[p]), i);
            int ind = pp - M[p].begin();
            l = max(ind - (ind == 0 and i <= M[p][0]), 0);
            // pv(l);
            // cout<<"less than "<<i<<" found in pos "<<l<<"\n";
        }
        q = a[i]*k;
        if(sz(M[q]))
        {
            // pv(q);
            // rep(j,sz(M[q]))
            //     cout<<M[q][j]<<" ";nl;
            auto pp = upper_bound(all(M[q]), i);
            int ind = pp - M[q].begin();
            r = sz(M[q]) - ind;
        }
        x += l*r;//*sz(M[a[i]]);
        // cout<<p<<" "<<a[i]<<" "<<q,nl;
        // cout<<l<<" "<<sz(M[a[i]])<<" "<<r,nl;
        // pv(x);
    }
    cout<<x,nl;
}

int main()
{
    fast

    // test
    // {
    	each_case();
    // }

    cin>>n;

    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
using namespace std;
ll n,m,k,x,y,p,q;
const int MAX = 2e5+1;
int a[MAX];
unordered_map<int, vi>M;

void each_case()
{
    M.clear();
    cin>>n>>k;
    rep(i,n)
        cin>>a[i], M[a[i]].pb(i);
    x=0;
    int l,r;
    bool done = false;
    rep(i,n)
    {
        // pv(a[i]);
        l = r = 0;
        if(a[i] == 1)
        {
            if( done == false)
            {
                ll fr = sz(M[a[i]]);
                x += (fr*(fr-1)*(fr-2))/6ll;
                // pv(x);
                done = true;
            }
            continue;
        }
        p = a[i]/k;
        if(sz(M[p]))
        {
            // pv(p);
            // rep(j,sz(M[p]))
            //     cout<<M[p][j]<<" ";nl;
            auto pp = lower_bound(all(M[p]), i);
            l = pp - M[p].begin();
            if(pp == M[p].begin())
                l = (a[M[p][0]] < a[i]);
            // pv(l);
            // cout<<"less than "<<i<<" found in pos "<<l<<"\n";
        }
        q = a[i]*k;
        if(sz(M[q]))
        {
            // pv(q);
            // rep(j,sz(M[q]))
            //     cout<<M[q][j]<<" ";nl;
            auto pp = upper_bound(all(M[q]), i);
            int ind = pp - M[q].begin();
            r = sz(M[q]) - ind;
        }
        x += l*r;//*sz(M[a[i]]);
        // cout<<p<<" "<<a[i]<<" "<<q,nl;
        // cout<<l<<" "<<sz(M[a[i]])<<" "<<r,nl;
        // pv(x);
    }
    cout<<x,nl;
}

int main()
{
    fast

    // test
    // {
    	each_case();
    // }

    cin>>n;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<long long, long long> m;
set<long long> s;
long long wyst[200007];
long long pary[200007];
int main(){
  long long n, k, nr = 0, res = 0;
  cin >> n >> k;
  long long v[n];
  for(long long i = 0;i < n;i++){
    cin >> v[i];
    s.insert(v[i]);
  }
  for(auto i : s)
    m[i] = ++nr;
  for(long long i = n - 1;i >= 0;i--){
    long long a = v[i];
    wyst[m[a]]++;
    pary[m[a]] += wyst[m[a * k]];
    res += pary[m[a * k]];
  }
  if(k == 1){
    res = 0;
    for(long long i = 1;i <= nr;i++)
      if(wyst[i] > 2)
        res += wyst[i] * (wyst[i] - 1) * (wyst[i] - 2) / 6;
  }
  cout << res;
}

/**
5 2
1 1 2 2 4
out:
4
**/


#include<bits/stdc++.h>
using namespace std;
map<long long, long long> m;
set<long long> s;
long long wyst[200007];
long long pary[200007];
long long main(){
  long long n, k, nr = 0, res = 0;
  cin >> n >> k;
  long long v[n];
  for(long long i = 0;i < n;i++){
    cin >> v[i];
    s.insert(v[i]);
  }
  for(auto i : s)
    m[i] = ++nr;
  for(long long i = n - 1;i >= 0;i--){
    long long a = v[i];
    wyst[m[a]]++;
    pary[m[a]] += wyst[m[a * k]];
    res += pary[m[a * k]];
  }
  if(k == 1){
    res = 0;
    for(long long i = 1;i <= nr;i++)
      if(wyst[i] > 2)
        res += wyst[i] * (wyst[i] - 1) * (wyst[i] - 2) / 6;
  }
  cout << res;
}

/**
5 2
1 1 2 2 4
out:
4
**/


#include<bits/stdc++.h>
using namespace std;
map<long long, long long> m;
set<long long> s;
long long wyst[200007];
long long pary[200007];
long long zera = 0;
int main(){
  long long n, k, nr = 0, res = 0;
  cin >> n >> k;
  long long v[n];
  for(long long i = 0;i < n;i++){
    cin >> v[i];
    s.insert(v[i]);
  }
  for(auto i : s)
    m[i] = ++nr;
  for(long long i = n - 1;i >= 0;i--){
    long long a = v[i];
    if(a == 0){
      zera++;
      continue;
    }
    wyst[m[a]]++;
    pary[m[a]] += wyst[m[a * k]];
    res += pary[m[a * k]];
  }
  if(k == 1){
    res = 0;
    for(long long i = 1;i <= nr;i++)
      if(wyst[i] > 2)
        res += wyst[i] * (wyst[i] - 1) * (wyst[i] - 2) / 6;
  }
  res += zera * (zera - 1) * (zera - 2) / 2;
  cout << res;
}

/**
5 2
1 1 2 2 4
out:
4
**/


#include<bits/stdc++.h>
using namespace std;
map<long long, long long> m;
set<long long> s;
long long wyst[200007];
long long pary[200007];
long long zera = 0;
int main(){
  long long n, k, nr = 0, res = 0;
  cin >> n >> k;
  long long v[n];
  for(long long i = 0;i < n;i++){
    cin >> v[i];
    s.insert(v[i]);
  }
  for(auto i : s)
    m[i] = ++nr;
  for(long long i = n - 1;i >= 0;i--){
    long long a = v[i];
    if(a == 0){
      zera++;
      continue;
    }
    wyst[m[a]]++;
    pary[m[a]] += wyst[m[a * k]];
    res += pary[m[a * k]];
  }
  if(k == 1){
    res = 0;
    for(long long i = 1;i <= nr;i++)
      if(wyst[i] > 2)
        res += wyst[i] * (wyst[i] - 1) * (wyst[i] - 2) / 6;
  }
  res += zera * (zera - 1) * (zera - 2) / 6;
  cout << res;
}

/**
5 2
1 1 2 2 4
out:
4
**/


#include<bits/stdc++.h>
using namespace std;
map<int, int> m;
set<int> s;
int wyst[200007];
int pary[200007];
int main(){
  int n, k, nr = 0, res = 0;
  cin >> n >> k;
  int v[n];
  for(int i = 0;i < n;i++){
    cin >> v[i];
    s.insert(v[i]);
  }
  for(auto i : s)
    m[i] = ++nr;
  for(int i = n - 1;i >= 0;i--){
    int a = v[i];
    wyst[m[a]]++;
    pary[m[a]] += wyst[m[a * k]];
    res += pary[m[a * k]];
  }
  if(k == 1){
    res = 0;
    for(int i = 1;i <= nr;i++)
      if(wyst[i] > 2)
        res += wyst[i] * (wyst[i] - 1) * (wyst[i] - 2) / 6;
  }
  cout << res;
}

/**
5 2
1 1 2 2 4
out:
4
**/


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[1000005];
map<long long,long long>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=3;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
         mp2[a[i]]--;
         mp1[a[i]]++;
     }
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[1000005];
map<long long,long long>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=2;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         mp2[a[i]]--;
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
         mp1[a[i]]++;
     }
     cout<<ans;
}


#include <bits/stdc++.h>
#define Killian "567C"
#define endl "\n"
#define pii pair <int,int>
#define bit(mask,u) (((mask)>>(u))&1)
using namespace std;
int n,k;
long long a[200005];
map <long long,long long> d1,d2;
long long res;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    d1[a[1]]=1;
    for (int i=n;i>=2;i--)
        d2[a[i]]++;
    for (int i=2;i<n;i++)
    {
        d2[a[i]]--;
        if (a[i]%k==0)
            res+=(d1[a[i]/k]*d2[a[i]*k]);
        d1[a[i]]++;
    }
    cout<<res;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[1000005];
map<long long,long long>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=3;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         mp2[a[i]]--;
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
         mp1[a[i]]++;
     }
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[1000005];
map<long long,long long>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=2;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         mp2[a[i]]--;
         mp1[a[i]]++;
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);

     }
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[100005];
map<long long,long long>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=2;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         mp2[a[i]]--;
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
         mp1[a[i]]++;
     }
     cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,d,res,a[1000005],k;
map<ll,ll>mp1,mp2;
main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    mp1[a[1]]=1;
    for(int i=2;i<=n;i++)
        mp2[a[i]]++;
    for(int i=2;i<n;i++)
    {
        mp2[a[i]]--; // giam mp2 cua ai
        if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
        mp1[a[i]]++;// tang mp1 cua ai
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[1000005];
map<long long,long long>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=2;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
         mp2[a[i]]--;
         mp1[a[i]]++;
     }
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,d,k,a[100005];
map<int,int>mp1,mp2;
main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     mp1[a[1]]=1;
     for(int i=2;i<=n;i++)
        mp2[a[i]]++;
     for(int i=2;i<n;i++)
     {
         mp2[a[i]]--;
         if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
         mp1[a[i]]++;
     }
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,ans,d,res,a[100005],k;
map<int,int>mp1,mp2;
main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    mp1[a[1]]=1;
    for(int i=2;i<=n;i++)
        mp2[a[i]]++;
    for(int i=2;i<n;i++)
    {
        mp2[a[i]]--; // giam mp2 cua ai
        if(a[i]%k==0)
            ans+=(mp1[a[i]/k]*mp2[a[i]*k]);
        mp1[a[i]]++;// tang mp1 cua ai
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%lld",&(x))
#define fi first
#define se second
#define mx 100001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%lld ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")

unordered_map<int,int> m1,m2;
main()
{
	//freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	int a[n];
	sd(a[0]);
	for(int i=1;i<n;i++)
		{
			sd(a[i]);
			if(m2.find(a[i])!=m2.end())
				m2[a[i]]++;
			else
				m2.insert(mp(a[i],1));
		}
	int ans = 0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]%k==0)
		{
			int s1,s2;
			if(m1.find(a[i]/k)==m1.end())
				s1=0;
			else s1 = m1[a[i]/k];
			if(m2.find(a[i]*k)!=m2.end())
				s2 = m2[a[i]*k];
			else
				s2 = 0;
			ans+=(s1*s2);
		}
		if(m1.find(a[i])!=m1.end())
			m1[a[i]]++;
		else
			m1.insert(mp(a[i],1));
		m2[a[i+1]]--;
		if(m2[a[i+1]]==0)
			m2.erase(a[i+1]);
	}
	pd(ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%lld",&(x))
#define fi first
#define se second
#define mx 1000001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%d ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) emplace_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")
#define spd ios::sync_with_stdio(false); cin.tie(0)

main()
{
	//freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	int a[n+1];
	fr(i,1,n+1)
	sd(a[i]);
	int dp[n+1];
	unordered_map<int,int> m,m1;
	dp[0] = 0;
	if(k!=1)
	{
	fr(i,1,n+1)
	{
		if(a[i]%(k*k)==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			if(m1.find(a[i]/k)==m1.end())
				dp[i] = dp[i-1];
			else
				dp[i] = dp[i-1]+m1[a[i]/k];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else if(a[i]%k==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			dp[i] = dp[i-1];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else
		{
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
			dp[i] = dp[i-1];
		}
	}
	//cout<<m1[1];
	pd(dp[n]);
	}
	else
	{
		unordered_map<int,int> m2;
		fr(i,1,n+1)
		{
			if(m2.find(a[i])==m2.end())
				m2.insert(mp(a[i],1));
			else
				m2[a[i]]++;
		}
		int s = 0;
		for(auto it = m2.begin();it!=m2.end();it++)
		{
			int z = it->se;
			s = s + z*(z-1)*(z-2)/6;
		}
		pd(s);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%d",&(x))
#define fi first
#define se second
#define mx 1000001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%d ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) emplace_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")
#define spd ios::sync_with_stdio(false); cin.tie(0)

main()
{
	//freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	int a[n+1];
	fr(i,1,n+1)
	sd(a[i]);
	int dp[n+1];
	unordered_map<int,int> m,m1;
	dp[0] = 0;
	if(k!=1)
	{
	fr(i,1,n+1)
	{
		if(a[i]%(k*k)==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			if(m1.find(a[i]/k)==m1.end())
				dp[i] = dp[i-1];
			else
				dp[i] = dp[i-1]+m1[a[i]/k];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else if(a[i]%k==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			dp[i] = dp[i-1];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else
		{
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
			dp[i] = dp[i-1];
		}
	}
	pd(dp[n]);
	}
	else
	{
		unordered_map<int,int> m2;
		fr(i,1,n+1)
		{
			if(m2.find(a[i])==m2.end())
				m2.insert(mp(a[i],1));
			else
				m2[a[i]]++;
		}
		int s = 0;
		for(auto it = m2.begin();it!=m2.end();it++)
		{
			int z = it->se;
			s = s + z*(z-1)*(z-2)/6;
		}
		pd(s);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%lld",&(x))
#define fi first
#define se second
#define mx 100001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%lld ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")

map<int,int> m1,m2;
main()
{
	//freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	int a[n];
	sd(a[0]);
	for(int i=1;i<n;i++)
		{
			sd(a[i]);
			if(m2.find(a[i])!=m2.end())
				m2[a[i]]++;
			else
				m2.insert(mp(a[i],1));
		}
	int ans = 0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]%k==0)
		{
			int s1,s2;
			if(m1.find(a[i]/k)==m1.end())
				s1=0;
			else s1 = m1[a[i]/k];
			if(m2.find(a[i]*k)!=m2.end())
				s2 = m2[a[i]*k];
			else
				s2 = 0;
			ans+=(s1*s2);
		}
		if(m1.find(a[i])!=m1.end())
			m1[a[i]]++;
		else
			m1.insert(mp(a[i],1));
		m2[a[i+1]]--;
		if(m2[a[i+1]]==0)
			m2.erase(a[i+1]);
	}
	pd(ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%lld",&(x))
#define fi first
#define se second
#define mx 1000001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%lld ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) emplace_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")
#define spd ios::sync_with_stdio(false); cin.tie(0)

int a[200001];
main()
{
	freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	fr(i,1,n+1)
	sd(a[i]);
	int dp[n+1];
	unordered_map<int,int> m,m1;
	dp[0] = 0;
	if(k!=1)
	{
	fr(i,1,n+1)
	{
		if(a[i]%(k*k)==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			if(m1.find(a[i]/k)==m1.end())
				dp[i] = dp[i-1];
			else
				dp[i] = dp[i-1]+m1[a[i]/k];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else if(a[i]%k==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			dp[i] = dp[i-1];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else
		{
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
			dp[i] = dp[i-1];
		}
	}
	pd(dp[n]);
	}
	else
	{
		unordered_map<int,int> m2;
		fr(i,1,n+1)
		{
			if(m2.find(a[i])==m2.end())
				m2.insert(mp(a[i],1));
			else
				m2[a[i]]++;
		}
		int s = 0;
		for(auto it = m2.begin();it!=m2.end();it++)
		{
			int z = it->se;
			int z1 = (z*(z-1)*(z-2))/6;
			s = s + z1;
		}
		pd(s);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%lld",&(x))
#define fi first
#define se second
#define mx 1000001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%lld ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) emplace_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")
#define spd ios::sync_with_stdio(false); cin.tie(0)

int a[200001];
main()
{
	//freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	fr(i,1,n+1)
	sd(a[i]);
	int dp[n+1];
	unordered_map<int,int> m,m1;
	dp[0] = 0;
	if(k!=1)
	{
	fr(i,1,n+1)
	{
		if(a[i]%(k*k)==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			if(m1.find(a[i]/k)==m1.end())
				dp[i] = dp[i-1];
			else
				dp[i] = dp[i-1]+m1[a[i]/k];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else if(a[i]%k==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			dp[i] = dp[i-1];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else
		{
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
			dp[i] = dp[i-1];
		}
	}
	pd(dp[n]);
	}
	else
	{
		unordered_map<int,int> m2;
		fr(i,1,n+1)
		{
			if(m2.find(a[i])==m2.end())
				m2.insert(mp(a[i],1));
			else
				m2[a[i]]++;
		}
		int s = 0;
		for(auto it = m2.begin();it!=m2.end();it++)
		{
			int z = it->se;
			int z1 = (z*(z-1)*(z-2))/6;
			s = s + z1;
		}
		pd(s);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld",&(x))
#define sd(x) scanf("%lld",&(x))
#define fi first
#define se second
#define mx 1000001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%d ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) emplace_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")
#define spd ios::sync_with_stdio(false); cin.tie(0)

main()
{
	//freopen("inputf.txt","r",stdin);
	int n,k;
	sd(n);
	sd(k);
	int a[n+1];
	fr(i,1,n+1)
	sd(a[i]);
	int dp[n+1];
	unordered_map<int,int> m,m1;
	dp[0] = 0;
	if(k!=1)
	{
	fr(i,1,n+1)
	{
		if(a[i]%(k*k)==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			if(m1.find(a[i]/k)==m1.end())
				dp[i] = dp[i-1];
			else
				dp[i] = dp[i-1]+m1[a[i]/k];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else if(a[i]%k==0)
		{
			if(m1.find(a[i])==m1.end())
			{
				if(m.find(a[i]/k)==m.end())
					m1.insert(mp(a[i],0));
				else
					m1.insert(mp(a[i],m[a[i]/k]));
			}
			else
			{
				if(m.find(a[i]/k)!=m.end())
					m1[a[i]]+=m[a[i]/k];
			}
			dp[i] = dp[i-1];
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
		}
		else
		{
			if(m.find(a[i])==m.end())
				m.insert(mp(a[i],1));
			else
				m[a[i]]++;
			dp[i] = dp[i-1];
		}
	}
	pd(dp[n]);
	}
	else
	{
		unordered_map<int,int> m2;
		fr(i,1,n+1)
		{
			if(m2.find(a[i])==m2.end())
				m2.insert(mp(a[i],1));
			else
				m2[a[i]]++;
		}
		int s = 0;
		for(auto it = m2.begin();it!=m2.end();it++)
		{
			int z = it->se;
			s = s + z*(z-1)*(z-2)/6;
		}
		pd(s);
	}
	return 0;
}


import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author interoperabilidad
 */
public class GeometricProgression {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        HashMap<Integer, Integer> ar = new HashMap<>();
        HashMap<Integer, Integer> al = new HashMap<>();
        int x[] = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = scanner.nextInt();
            if(ar.get(x[i]) != null){
                ar.put(x[i], ar.get(x[i])+1);
            }else{
                ar.put(x[i], 1);
            }
        }
        long res = 0;
        for(int i = 0; i < n; i++){
            ar.put(x[i], ar.get(x[i]) - 1);
            if(x[i] % k == 0){
                Integer b = al.get(x[i]/k);
                if(b == null){
                    b = 0;
                    al.put(x[i]/k, 0);
                }
                Integer a = ar.get(x[i]*k);
                if(a == null){
                    a = 0;
                    ar.put(x[i]*k, 0);
                }
                res += (long)a*(long)b;
            }
            Integer a = al.get(x[i]);
            if(a == null){
                a = 0;
                al.put(x[i], a);
            }
            al.put(x[i], a+1);
        }
        System.out.println(res);
    }

}


import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author interoperabilidad
 */
public class GeometricProgression {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        HashMap<Long, Integer> ar = new HashMap<>();
        HashMap<Long, Integer> al = new HashMap<>();
        long x[] = new long[n];
        for(int i = 0; i < n; i++){
            x[i] = scanner.nextLong();
            if(ar.get(x[i]) != null){
                ar.put(x[i], ar.get(x[i])+1);
            }else{
                ar.put(x[i], 1);
            }
        }
        long res = 0;
        for(int i = 0; i < n; i++){
            ar.put(x[i], ar.get(x[i]) - 1);
            if(x[i] % k == 0){
                Integer b = al.get(x[i]/k);
                if(b == null){
                    b = 0;
                    al.put(x[i]/k, 0);
                }
                Integer a = ar.get(x[i]*k);
                if(a == null){
                    a = 0;
                    ar.put(x[i]*k, 0);
                }
                res += (long)a*(long)b;
            }
            Integer a = al.get(x[i]);
            if(a == null){
                a = 0;
                al.put(x[i], a);
            }
            al.put(x[i], a+1);
        }
        System.out.println(res);
    }

}


import java.io.*;
import java.util.*;

public class Program {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    static final int MOD = 1000000007;
    static final double INF = 10000000000.0;

	void solve() throws IOException {
		long n, k, a[];
		n = nextInt();
		k = nextInt();
		a = new long[(int)n];
		HashMap<Long, Integer> lf, rf;
		lf = new HashMap<>();
		rf = new HashMap<>();
		for(int i = 0; i < n; i++)
		{
			a[i] = nextInt();
			if (rf.containsKey(a[i]))
				rf.put(a[i], rf.get(a[i])+1);
			else
				rf.put(a[i], 1);
		}
		long ans = 0;
		for(int i = 0; i < n; i++)
		{
			long k1 = 0, k2 = 0;
			rf.put(a[i], rf.get(a[i])-1);
			if (lf.containsKey(a[i]/k))
				k1 = lf.get(a[i]/k);
			if (rf.containsKey(a[i]*k))
				k2 = rf.get(a[i]*k);
			if (lf.containsKey(a[i]))
				lf.put(a[i], lf.get(a[i])+1);
			else
				lf.put(a[i], 1);
			if (a[i] % k == 0)
				ans += k1 * k2;
		}
		out.println(ans);
	}

    Program() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Program();
    }

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }

    String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


import java.io.*;
import java.math.*;
import java.util.*;

public class Program {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    static final int MOD = 1000000007;
    static final double INF = 10000000000.0;
    static final int MAX = 1000001;

    int lbin(int[] a, int x)
    {
    	int l, r, m;
    	l = 0;
    	r = a.length-1;
    	while(r-l > 1)
    	{
    		m = l + (r-l)/2;
    		if (a[m] >= x)
    			r = m;
    		else
    			l = m+1;
    	}
    	if (a[l] == x)
    		return l;
    	else if (a[r] == x)
    		return r;
    	else
    		return -1;
    }

    int rbin(int[] a, int x)
    {
    	int l, r, m;
    	l = 0;
    	r = a.length-1;
    	while(r-l > 1)
    	{
    		m = l + (r-l)/2;
    		if (a[m] < x)
    			l = m+1;
    		else if (a[m] > x)
    			r = m-1;
    		else
    			l = m;
    	}
    	if (a[r] == x)
    		return r;
    	else if (a[l] == x)
    		return l;
    	else
    		return -1;
    }

 	void solve() throws IOException {
 		int n, k, a[];
 		Set<Integer> s = new HashSet<>();
 		n = nextInt();
 		k = nextInt();
 		a = new int[n];
 		for(int i = 0; i < n; i++)
 		{
 			a[i] = nextInt();
 			s.add(a[i]);
 		}
 		Arrays.sort(a);
 		int ans = 0;
 		for(int x : s)
 		{
 			if (k == 1)
 			{
 				if (rbin(a, x) - lbin(a, x) >= 2)
 					ans ++;
 			}
 			else if (lbin(a, x) != -1 && lbin(a, x*k) != -1 && lbin(a, x*k*k) != -1)
 			{
 				int r1, r2, r3;
 				r1 = rbin(a, x) - lbin(a, x) + 1;
 				r2 = rbin(a, x*k) - lbin(a, x*k) + 1;
 				r3 = rbin(a, x*k*k) - lbin(a, x*k*k) + 1;
 				ans += r1*r2*r3;
 			}
 		}
 		out.println(ans);
    }

    Program() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Program();
    }

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }

    String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    class Pair implements Comparable<Pair>{

        int first, second;

        public Pair(int an1, int an2){
            first = an1;
            second = an2;
        }

        @Override
        public int compareTo(Pair o) {
            if (first - o.first == 0)
            	return second - o.second;
            else
            	return first - o.first;
        }
    }
}


import java.io.*;
import java.util.*;

public class Program {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    static final int MOD = 1000000007;
    static final double INF = 10000000000.0;

	void solve() throws IOException {
		int n, k, a[];
		n = nextInt();
		k = nextInt();
		a = new int[n];
		HashMap<Integer, Integer> lf, rf;
		lf = new HashMap<>();
		rf = new HashMap<>();
		for(int i = 0; i < n; i++)
		{
			a[i] = nextInt();
			if (rf.containsKey(a[i]))
				rf.put(a[i], rf.get(a[i])+1);
			else
				rf.put(a[i], 1);
		}
		long ans = 0;
		for(int i = 0; i < n; i++)
		{
			long k1 = 0, k2 = 0;
			rf.put(a[i], rf.get(a[i])-1);
			if (lf.containsKey(a[i]/k))
				k1 = lf.get(a[i]/k);
			if (rf.containsKey(a[i]*k))
				k2 = rf.get(a[i]*k);
			if (lf.containsKey(a[i]))
				lf.put(a[i], lf.get(a[i])+1);
			else
				lf.put(a[i], 1);
			if (a[i] % k == 0)
				ans += k1 * k2;
		}
		out.println(ans);
	}

    Program() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Program();
    }

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }

    String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class R314Div2C {
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		long k=in.nextLong();
		long[] a=new long[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextLong();
		HashMap<Long,long[]> map=new HashMap<Long,long[]>();
		for(int i=0;i<n;i++){
			long[] v=new long[3];
			if(map.containsKey(a[i]))
				v=map.get(a[i]);
			if(Math.abs(a[i])>=(k*k)&&Math.abs(a[i])%(k*k)==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[2]+=map.get(b)[1];
			}
			if(Math.abs(a[i])>=k&&Math.abs(a[i])%k==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[1]+=map.get(b)[0];
			}
			v[0]++;
			map.put(a[i],v);
		}
		long ans=0;
		for(long key:map.keySet()){
			ans+=map.get(key)[2];
		}
		System.out.println(ans);
	}
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(){br=new BufferedReader(new InputStreamReader(System.in));}
		String nextToken(){
			while(st==null||!st.hasMoreElements())
				try{st=new StringTokenizer(br.readLine());}catch(Exception e){}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(nextToken());}
		long nextLong(){return Long.parseLong(nextToken());}
		double nextDouble(){return Double.parseDouble(nextToken());}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class R314Div2C {
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		long k=in.nextLong();
		long[] a=new long[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextLong();
		HashMap<Long,long[]> map=new HashMap<Long,long[]>();
		for(int i=0;i<n;i++){
			long[] v=new long[3];
			if(map.containsKey(a[i]))
				v=map.get(a[i]);
			if(Math.abs(a[i])%(k*k)==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[2]+=map.get(b)[1];
			}
			if(Math.abs(a[i])%k==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[1]+=map.get(b)[0];
			}
			v[0]++;
			map.put(a[i],v);
		}
		long ans=0;
		for(long key:map.keySet()){
			ans+=map.get(key)[2];
		}
		System.out.println(ans);
	}
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(){br=new BufferedReader(new InputStreamReader(System.in));}
		String nextToken(){
			while(st==null||!st.hasMoreElements())
				try{st=new StringTokenizer(br.readLine());}catch(Exception e){}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(nextToken());}
		long nextLong(){return Long.parseLong(nextToken());}
		double nextDouble(){return Double.parseDouble(nextToken());}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class R314Div2C {
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		long k=in.nextLong();
		long[] a=new long[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextLong();
		HashMap<Long,long[]> map=new HashMap<Long,long[]>();
		for(int i=0;i<n;i++){
			long[] v=new long[3];
			if(map.containsKey(a[i]))
				v=map.get(a[i]);
			if(Math.abs(a[i])>=(k*k)&&Math.abs(a[i])%(k*k)==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[2]+=map.get(b)[1];
			}
			if(Math.abs(a[i])>=k&&Math.abs(a[i])%k==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[1]+=map.get(b)[0];
			}
			v[0]++;
			map.put(a[i],v);
		}
		int ans=0;
		for(long key:map.keySet()){
			ans+=map.get(key)[2];
		}
		System.out.println(ans);
	}
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(){br=new BufferedReader(new InputStreamReader(System.in));}
		String nextToken(){
			while(st==null||!st.hasMoreElements())
				try{st=new StringTokenizer(br.readLine());}catch(Exception e){}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(nextToken());}
		long nextLong(){return Long.parseLong(nextToken());}
		double nextDouble(){return Double.parseDouble(nextToken());}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class R314Div2C {
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		long k=in.nextLong();
		long[] a=new long[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextLong();
		HashMap<Long,long[]> map=new HashMap<Long,long[]>();
		for(int i=0;i<n;i++){
			long[] v=new long[3];
			if(map.containsKey(a[i]))
				v=map.get(a[i]);
			if(k==0||Math.abs(a[i])>=(k*k)&&Math.abs(a[i])%(k*k)==0){
				long b=k==0?0:a[i]/k;
				if(map.containsKey(b))
					v[2]+=map.get(b)[1];
			}
			if(k==0||Math.abs(a[i])>=k&&Math.abs(a[i])%k==0){
				long b=k==0?0:a[i]/k;
				if(map.containsKey(b))
					v[1]+=map.get(b)[0];
			}
			v[0]++;
			map.put(a[i],v);
		}
		long ans=0;
		for(long key:map.keySet()){
			ans+=map.get(key)[2];
		}
		System.out.println(ans);
	}
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(){br=new BufferedReader(new InputStreamReader(System.in));}
		String nextToken(){
			while(st==null||!st.hasMoreElements())
				try{st=new StringTokenizer(br.readLine());}catch(Exception e){}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(nextToken());}
		long nextLong(){return Long.parseLong(nextToken());}
		double nextDouble(){return Double.parseDouble(nextToken());}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class R314Div2C {
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		long k=in.nextLong();
		long[] a=new long[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextLong();
		HashMap<Long,int[]> map=new HashMap<Long,int[]>();
		for(int i=0;i<n;i++){
			int[] v=new int[3];
			if(map.containsKey(a[i]))
				v=map.get(a[i]);
			if(Math.abs(a[i])>=(k*k)&&Math.abs(a[i])%(k*k)==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[2]+=map.get(b)[1];
			}
			if(Math.abs(a[i])>=k&&Math.abs(a[i])%k==0){
				long b=a[i]/k;
				if(map.containsKey(b))
					v[1]+=map.get(b)[0];
			}
			v[0]++;
			map.put(a[i],v);
		}
		int ans=0;
		for(long key:map.keySet()){
			ans+=map.get(key)[2];
		}
		System.out.println(ans);
	}
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(){br=new BufferedReader(new InputStreamReader(System.in));}
		String nextToken(){
			while(st==null||!st.hasMoreElements())
				try{st=new StringTokenizer(br.readLine());}catch(Exception e){}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(nextToken());}
		long nextLong(){return Long.parseLong(nextToken());}
		double nextDouble(){return Double.parseDouble(nextToken());}
	}
}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class MainC {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = sc.nextLongArray(n);
		if (n <= 2) {
			System.out.println(0);
			return;
		} else if (k == 1) {
			HashMap<Long, Long> map = new HashMap<Long, Long>();
			for (int i = 0; i < n; i++) {
				map.put(a[i], map.containsKey(a[i]) ? map.get(a[i]) + 1 : 1);
			}
			long cnt = 0;
			for (Long key : map.keySet()) {
				long val = map.get(key);
				if (val <= 2) {
					// none
				} else if (val == 3) {
					cnt++;
				} else {
					long ll = 1;
					ll *= val * (val - 1) * (val - 2);
					ll /= 6;
					cnt += ll;
				}
			}
			System.out.println(cnt);
			return;
		}
		long ans = 0;
		HashMap<Long, Long> one = new HashMap<Long, Long>();
		HashMap<Long, Long> two = new HashMap<Long, Long>();
		for (int i = 0; i < n; i++) {
			if (one.containsKey(a[i])) {
				one.put(a[i], one.get(a[i]) + 1);
			} else {
				one.put(a[i], 1L);
			}
			if (a[i] % k == 0 && a[i] / k != 0 && one.containsKey(a[i] / k)) {
				if (two.containsKey(a[i])) {
					two.put(a[i], two.get(a[i]) + one.get(a[i] / k));
				} else {
					two.put(a[i], one.get(a[i] / k));
				}
			}
			if (a[i] % k == 0 && a[i] / k != 0 && two.containsKey(a[i] / k)) {
				ans += two.get(a[i] / k);
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new MainC().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class MainC {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = sc.nextLongArray(n);
		if (n <= 2) {
			System.out.println(0);
			return;
		} else if (k == 1) {
			HashMap<Long, Long> map = new HashMap<Long, Long>();
			for (int i = 0; i < n; i++) {
				map.put(a[i], map.containsKey(a[i]) ? map.get(a[i]) + 1 : 1);
			}
			long cnt = 0;
			for (Long key : map.keySet()) {
				long val = map.get(key);
				if (val <= 2) {
					// none
				} else if (val == 3) {
					cnt++;
				} else {
					long ll = 1;
					ll *= val * (val - 1) * (val - 2);
					ll /= 6;
					cnt += ll;
				}
			}
			System.out.println(cnt);
			return;
		}
		long ans = 0;
		HashMap<Long, Long> one = new HashMap<Long, Long>();
		HashMap<Long, Long> two = new HashMap<Long, Long>();
		for (int i = 0; i < n; i++) {
			if (a[i] % k == 0 && two.containsKey(a[i] / k)) {
				ans += two.get(a[i] / k);
			}
			if (a[i] % k == 0 && one.containsKey(a[i] / k)) {
				if (two.containsKey(a[i])) {
					two.put(a[i], two.get(a[i]) + one.get(a[i] / k));
				} else {
					two.put(a[i], one.get(a[i] / k));
				}
			}
			if (one.containsKey(a[i])) {
				one.put(a[i], one.get(a[i]) + 1);
			} else {
				one.put(a[i], 1L);
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new MainC().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = sc.nextIntArray(n);
		HashMap<Integer, Long> one = new HashMap<Integer, Long>();
		HashMap<Integer, Long> two = new HashMap<Integer, Long>();
		long cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % k == 0 && two.containsKey(a[i] / k)) {
				cnt += two.get(a[i] / k);
			}
			if (a[i] % k == 0 && one.containsKey(a[i] / k)) {
				long t = two.containsKey(a[i]) ? two.get(a[i]) : 0;
				two.put(a[i], t + one.get(a[i] / k));
			}
			one.put(a[i], one.containsKey(a[i]) ? one.get(a[i]) + 1 : 1);
		}
		System.out.println(cnt);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class MainC {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = sc.nextLongArray(n);
		if (n <= 2) {
			System.out.println(0);
			return;
		} else if (k == 1) {
			HashMap<Long, Long> map = new HashMap<Long, Long>();
			for (int i = 0; i < n; i++) {
				map.put(a[i], map.containsKey(a[i]) ? map.get(a[i]) + 1 : 1);
			}
			long cnt = 0;
			for (Long key : map.keySet()) {
				long val = map.get(key);
				if (val <= 2) {
					// none
				} else if (val == 3) {
					cnt++;
				} else {
					long ll = 1;
					ll *= val * (val - 1) * (val - 2);
					ll /= 6;
					cnt += ll;
				}
			}
			System.out.println(cnt);
			return;
		}
		long ans = 0;
		HashMap<Long, Long> one = new HashMap<Long, Long>();
		HashMap<Long, Long> two = new HashMap<Long, Long>();
		for (int i = 0; i < n; i++) {
			if (one.containsKey(a[i])) {
				one.put(a[i], one.get(a[i]) + 1);
			} else {
				one.put(a[i], 1L);
			}
			if (a[i] % k == 0 && one.containsKey(a[i] / k)) {
				if (two.containsKey(a[i])) {
					two.put(a[i], two.get(a[i]) + one.get(a[i] / k));
				} else {
					two.put(a[i], one.get(a[i] / k));
				}
			}
			if (a[i] % k == 0 && two.containsKey(a[i] / k)) {
				ans += two.get(a[i] / k);
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new MainC().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}