static long permutation(int [] A, int n, int v){
			
			long count = 0; // Let count be the number of all possible permutations in P(n,k)
			
			Arrays.sort(A); // Sort the array in lexical order
			
			do{
				count = visit(A, n, v, count); // visit A[1...n]
				
				// Find the max j with A[j] > A[j+1], scanning from right to left
				int j = n-1; 
				while(A[j] >= A[j+1]){
					if(j == 1) return count;	// If j=1 then break
					j--;
				}
				
				// Find the max l with A[j] >= A[l], scanning from right to left
				int l = n;
				while(A[j] >= A[l]){
					l--;
				}
				
				// Exchange A[j] and A[l]
				swap(A, j, l);
				
				// Reverse A[j+1...n]
				for(int left = j+1, right = n; left < right ; left++, right--){
					swap(A, left, right);
				}
				
			} while(true);	// forever looping until j=1
				
		}