class Solution {
public:
  vector<int> FindNumbersWithSum(vector<int> array,int target) {

    vector<int> ans(2);
    int min_product = INT_MAX;
    int l = 0, r = array.size() - 1;

    bool flag = false;
    while (l < r) {
      int sum = array[l] + array[r];
      int product = array[l] * array[r];
      if (sum == target) {
        flag = true;
        if (product < min_product) {
          min_product = product;
          ans.front() = array[l];
          ans.back()  = array[r];
        }
        ++l, --r;
      }
      if (sum < target) ++l;
      else --r;
    }

    return flag ? ans : vector<int>();
  }
};