#include <algorithm>
#include <unordered_map>
class FindPair {
  public:
    int countPairs(vector<int> A, int n, int sum) {
        // write code here
        unordered_map<int, int> left_map;
        int count =0;
        for(auto a:A){
            count+= left_map[sum-a];
            left_map[a]++;
        }
        return  count;
    }
};