Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.

He wants to know how many subsequences of length three can be selected from a, so that they form a geometric progression with common ratio k.

A subsequence of length three is a combination of three such indexes i1, i2, i3, that 1 ≤ i1 < i2 < i3 ≤ n. That is, a subsequence of length three are such groups of three elements that are not necessarily consecutive in the sequence, but their indexes are strictly increasing.

A geometric progression with common ratio k is a sequence of numbers of the form b·k0, b·k1, ..., b·kr - 1.

Polycarp is only three years old, so he can not calculate this number himself. Help him to do it.

Input

The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number.

The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.

Output

Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.

Examples

Input

5 2
1 1 2 2 4


Output

4

Input

3 1
1 1 1


Output

1

Input

10 3
1 2 6 2 3 6 9 18 3 9


Output

6

Note

In the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
import java.io.*;
import java.util.*;



public class Main
{
	public static void main(String[] args) {
	    int n=ni(),k=ni();
	    int []a=nia(n);
	    HM<Long,Integer> hm=new HM<>(),mh=new HM<>();
	    long pre[]=new long[n];
	    for(int i=0;i<n;i++)
	    {
	        
	        if(a[i]%k==0 && hm.get((long)a[i]/k)!=null) {
	        pre[i]=hm.get((long)a[i]/k);}
	        if(hm.get((long)a[i])==null) {hm.put((long)a[i],0);mh.put((long)a[i],0);}
	        hm.put((long)a[i],hm.get((long)a[i])+1);

	    }
	    // print(pre);
	    long ans=0;
	    for(int i=n-1;i>=0;i--)
	    {
	       
	        if(mh.get((long)a[i]*k)!=null) ans=ans+pre[i]*mh.get((long)a[i]*k);
	         mh.put((long)a[i],mh.get((long)a[i])+1);
	    }
	    pln(ans);
	    flush();
	}
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static final long mod=1000_000_007;
	static final long iinf=1000_000_000L;
	static final long linf=1000_000_000_000_000_000L;
	
	//input functions
	static int ni(){return Integer.parseInt(in.next());}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	
	//output functions 
	static void print(int a[]){for(int i:a) System.out.print(i+" "); System.out.println();}
	static void print(long a[]){for(long i:a) System.out.print(i+" "); System.out.println();}
	static void print(double a[]){for(double i:a) System.out.print(i+" "); System.out.println();}
	static void print(Object... a){for(Object i:a) {System.out.print(i);System.out.print(" ");} System.out.println();}
	static void println(Object... a){for(Object i:a) {System.out.print(i);System.out.print("\n");}}
	static void println(){System.out.println();}
	static void flush(){System.out.print(output);output=new StringBuilder();}
	static void pln(Object... a){for(Object i:a){output.append(i).append('\n');}}
	static void pln(){output.append('\n');}
	static void p(Object... a){for(Object i:a) output.append(i);}
	static void ps(Object... a){for(Object i:a){output.append(i).append(" ");}}
	static void ps(){output.append(" ");}
	
	
	//Utility functions
	static long powm(long a, long b, long mod){long an=1;long c=a%mod;while(b>0){if(b%2==1)an=(an*c)%mod;c=(c*c)%mod;b>>=1;}return an;}
	static long powm(long a, long b){long an=1;long c=a%mod;while(b>0){if(b%2==1)an=(an*c)%mod;c=(c*c)%mod;b>>=1;}return an;}
	static long pow(long a, long b){long an=1;long c=a;while(b>0){if(b%2==1)an*=c;c*=c;b>>=1;}return an;}
	static int gcd(int a, int b){if(b==0)return a;if(a==0) return b; return gcd(b, a%b);}
	static long gcd(long a, long b){if(b==0)return a;if(a==0) return b;return gcd(b, a%b);}
	static void reverse(int[]a){for(int i=0; i<a.length/2; i++){a[i]^=a[a.length-i-1];a[a.length-i-1]^=a[i];a[i]^=a[a.length-i-1];}}
	static void exit(){System.exit(0);}
	static int min(int... a){int min=a[0];for(int i:a)min=Math.min(min, i);return min;}
	static int max(int... a){int max=a[0];for(int i:a)max=Math.max(max, i);return max;}	
	static int gcd(int... a){int gcd=a[0];for(int i:a)gcd=gcd(gcd, i);return gcd;}	
	static long min(long... a){long min=a[0];for(long i:a)min=Math.min(min, i);return min;}
	static long max(long... a){long max=a[0];for(long i:a)max=Math.max(max, i);return max;}	
	static long gcd(long... a){long gcd=a[0];for(long i:a)gcd=gcd(gcd, i);return gcd;}
	static double min(double... a){double min=a[0];for(double i:a)min=Math.min(min, i);return min;}
	static double max(double... a){double max=a[0];for(double i:a)max=Math.max(max, i);return max;}	
	
	static class Pair
	{
	    long la,lb; 
	    int a,b;
	    double da,db;
	    Pair(){} Pair(int c,int d){a=c;b=d;}
	    Pair(long c,long d){la=c;lb=d;}
	    Pair(int c,long d){ a=c;lb=d; }
	    Pair(long c,int d){ la=c;b=d; }
	    Pair(int c,double d){ a=c;db=d; }
	    Pair(double c,double d){ da=c;db=d; }
	    Pair(double c,int d) { da=c;b=d; }
	    
		@Override
		public int hashCode() { return (a+" "+b).hashCode(); }
		public boolean equals(Object c) { return (a==(((Pair)c).a)&&b==(((Pair)c).b)); }
	}
	
	static class Reader{
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

class AL<T> extends java.util.ArrayList<T>{}
class HM<T,L> extends java.util.HashMap<T,L>{}
class HS<T> extends java.util.HashSet<T>{}