description: Bob really likes playing with arrays of numbers. That's why for his birthday, his friends bought him a really interesting machine – an array beautifier. 
  
  The array beautifier takes an array A consisting of N integers, and it outputs a new array B of length N that it constructed based on the array given to it. The array beautifier constructs the new array in the following way: it takes two numbers at different indices from the original array and writes their sum to the end of the new array. It does this step N times - resulting in an output array of length N. During this process, the machine can take the same index multiple times in different steps. 
  
  Bob was very excited about the gift that his friends gave him, so he put his favorite array in the machine. However, when the machine finished, Bob was not happy with the resulting array. He misses his favorite array very much, and hopes to get it back. 
  
  Given the array that the machine outputted, help Bob find an array that could be the original array that he put in the machine. Sometimes the machine makes mistakes, so it is possible that no appropriate input array exists for the array it has outputted. In such case, let Bob know that his array is forever lost.
  
  Input
  
  The first line contains one positive integer N (2 ≤ N ≤ 10^3) – the length of Bob's array.
  
  The second line contains N integers B_1, B_2, ..., B_N (1 ≤ B_i ≤ 10^6) – the elements of the array the machine outputted.
  
  Output
  
  If an appropriate input array exists, print "YES", followed by the input array A_1, A_2, ..., A_N (-10^9 ≤ A_i ≤ 10^9) in the next line. Otherwise, print "NO".
  
  Examples
  
  Input
  
  
  2
  5 5
  
  
  Output
  
  
  YES
  2 3
  
  
  Input
  
  
  3
  1 2 3
  
  
  Output
  
  
  YES
  0 1 2
  
  
  Input
  
  
  3
  2 4 5
  
  
  Output
  
  
  NO
  
  
  Input
  
  
  4
  1 3 5 7
  
  
  Output
  
  
  YES
  6 -3 4 1
solution: #include <bits/stdc++.h>
  namespace cm {
  class logger {
   private:
    std::ostream* out;
    std::string sep = "\x2c\x20";
    bool _assert_exit = true;
    std::string c_red = "\033[0;31m";
    std::string c_green = "\033[0;32m";
    std::string c_yellow = "\033[0;33m";
    std::string c_blue = "\033[0;34m";
    std::string c_magenta = "\033[0;35m";
    std::string c_cyan = "\033[0;36m";
    std::string c_red_bold = "\033[1;31m";
    std::string c_green_bold = "\033[1;32m";
    std::string c_yellow_bold = "\033[1;33m";
    std::string c_blue_bold = "\033[1;34m";
    std::string c_magenta_bold = "\033[1;35m";
    std::string c_cyan_bold = "\033[1;36m";
    std::string c_reset = "\033[0m";
    std::string get_color(std::string name) {
      if (name == "red") return c_red;
      if (name == "green") return c_green;
      if (name == "yellow") return c_yellow;
      if (name == "blue") return c_blue;
      if (name == "magenta") return c_magenta;
      if (name == "cyan") return c_cyan;
      if (name == "red bold") return c_red_bold;
      if (name == "green bold") return c_green_bold;
      if (name == "yellow bold") return c_yellow_bold;
      if (name == "blue bold") return c_blue_bold;
      if (name == "magenta bold") return c_magenta_bold;
      if (name == "cyan bold") return c_cyan_bold;
      if (name == "reset") return c_reset;
      return "";
    }
  
   public:
    logger(std::ostream& out) : out(&out) {}
    logger& set_ostream(std::ostream& out) {
      this->out = &out;
      return *this;
    }
    logger& set_sep(const std::string& sep) {
      this->sep = sep;
      return *this;
    }
    logger& assert_exit() {
      _assert_exit = true;
      return *this;
    }
    logger& assert_noexit() {
      _assert_exit = false;
      return *this;
    }
    logger& endl() {
      *out << std::endl;
      return *this;
    }
    logger& log() { return *this; }
    template <class Ta, class Tb, class... Tc>
    logger& log(const Ta& a, const Tb& b, Tc... c) {
      return log(a).log(sep).log(b, c...);
    }
    template <class Ta, typename = decltype(std::cout << std::declval<Ta>())>
    logger& log(const Ta& a) {
      *out << a;
      return *this;
    }
    template <class T, typename = decltype(std::declval<T>().begin()),
              typename = decltype(std::declval<T>().end()),
              typename = typename std::enable_if<!std::is_base_of<
                  std::string, typename std::decay<T>::type>::value>::type,
              typename value_type = typename T::value_type>
    logger& log(const T& container) {
      log("{");
      for (auto it = container.begin(); it != container.end(); ++it) {
        if (it != container.begin()) log(sep);
        log(*it);
      }
      log("}");
      return *this;
    }
    template <class Ta, class Tb>
    logger& log(const std::pair<Ta, Tb>& x) {
      return log("(").log(x.first, x.second).log(")");
    }
    template <class... T>
    logger& log(const std::tuple<T...>&) {
      return log("<tuple>");
    }
    template <class T>
    logger& hint(const T& x, std::string color = "cyan") {
      color = get_color(color);
      return log(color).log(x).log("\x3a\x20").log(c_reset);
    }
    template <class... T>
    logger& operator()(T... value) {
      return log(value...).endl();
    }
    template <class... T>
    logger& _assert(const std::string& file, int line, const std::string& raw,
                    bool value, const std::string& info_str, T... info) {
      if (!value) {
        endl();
        hint(file, "magenta")
            .hint(line, "magenta")
            .log(c_yellow)
            .log("Assertion `")
            .log(c_yellow_bold)
            .log(raw)
            .log(c_yellow)
            .log("` failed")
            .log(c_reset)
            .endl();
        if (info_str != "") hint("detail", "magenta").hint(info_str)(info...);
        if (_assert_exit) exit(0);
      }
      return *this;
    }
  };
  namespace impl {
  logger see_logger(std::cout);
  }
  }  // namespace cm
  namespace cm {
  template <class Type, size_t buf_size>
  class buffer_reader {
   protected:
    FILE* src;
    Type* const buff;
    Type* buff_end;
    Type* buff_pos;
    void flush() {
      buff_end = buff + fread(buff, sizeof(Type), buf_size, src);
      buff_pos = buff;
      if (buff_end == buff) {
        *buff_end = '\0';
      }
    }
  
   public:
    buffer_reader(FILE* src) : src(src), buff(new Type[buf_size]) { flush(); }
    buffer_reader(const buffer_reader&) = delete;
    buffer_reader(buffer_reader&&) = delete;
    buffer_reader& operator=(const buffer_reader&) = delete;
    buffer_reader& operator=(buffer_reader&&) = delete;
    Type get() const { return *buff_pos; }
    Type next() {
      Type result = get();
      buff_pos++;
      if (buff_pos == buff_end) flush();
      return result;
    }
    ~buffer_reader() {
      fclose(src);
      delete[] buff;
    }
  };
  using optimal_reader = buffer_reader<char, 1 << 16>;
  template <class BufferReader>
  class scanner : protected BufferReader {
   private:
    using BufferReader::get;
    using BufferReader::next;
    inline bool is_ws(char c) { return c <= ' '; }
    inline bool is_cr(char c) { return c == '\n' || c == '\r'; }
    int get_sign() {
      while (!isdigit(get()) && get() != '-') next();
      if (get() == '-') return next(), -1;
      return 1;
    }
  
   public:
    scanner() = delete;
    using BufferReader::BufferReader;
    char next_char() {
      while (is_ws(get())) next();
      return next();
    }
    char* next_token(char* s) {
      while (is_ws(get())) next();
      while (!is_ws(get())) *s++ = next();
      *s = '\0';
      return s;
    }
    char* next_line(char* s) {
      while (is_ws(get())) next();
      while (!is_cr(get())) *s++ = next();
      *s = '\0';
      return s;
    }
    int next_int() {
      int sign = get_sign();
      int result = 0;
      while (isdigit(get())) result = result * 10 + (next() - '0');
      return sign * result;
    }
    long long next_long() {
      int sign = get_sign();
      long long result = 0;
      while (isdigit(get())) result = result * 10 + (next() - '0');
      return sign * result;
    }
    long long next_modint(long long mod) {
      get_sign();
      long long result = 0;
      while (isdigit(get())) result = (result * 10 + (next() - '0')) % mod;
      return result;
    }
    double next_double() {
      int sign = get_sign();
      double result = 0;
      while (isdigit(get())) result = result * 10 + (next() - '0');
      if (get() == '.') {
        next();
        double cur_ep = 0.1;
        while (isdigit(get())) result += cur_ep * (next() - '0'), cur_ep *= 0.1;
      }
      return sign * result;
    }
  };
  }  // namespace cm
  namespace cm {
  template <class T>
  inline bool check_min(T& a, const T& b) {
    return b < a ? a = b, 1 : 0;
  }
  template <class T>
  inline bool check_max(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
  }
  struct once_t {
    bool once = true;
    bool operator()() { return once ? (once = false, true) : false; }
  };
  }  // namespace cm
  using cm::check_max;
  using cm::check_min;
  template <class A, class B>
  inline __attribute__((always_inline)) std::pair<A, B> operator+(
      const std::pair<A, B>& lhs, const std::pair<A, B>& rhs) {
    return std::make_pair(lhs.first + rhs.first, lhs.second + rhs.second);
  }
  template <class A, class B>
  inline __attribute__((always_inline)) std::pair<A, B> operator-(
      const std::pair<A, B>& lhs, const std::pair<A, B>& rhs) {
    return std::make_pair(lhs.first - rhs.first, lhs.second - rhs.second);
  }
  template <class A, class B>
  inline __attribute__((always_inline)) std::pair<A, B>& operator+=(
      std::pair<A, B>& lhs, const std::pair<A, B>& rhs) {
    lhs.first += rhs.first;
    lhs.second += rhs.second;
    return lhs;
  }
  template <class A, class B>
  inline __attribute__((always_inline)) std::pair<A, B>& operator-=(
      std::pair<A, B>& lhs, const std::pair<A, B>& rhs) {
    lhs.first -= rhs.first;
    lhs.second -= rhs.second;
    return lhs;
  }
  template <class T>
  std::vector<T>& operator+=(std::vector<T>& a, const std::vector<T>& b) {
    a.insert(a.end(), b.begin(), b.end());
    return a;
  }
  template <class T>
  std::vector<T>& operator+=(std::vector<T>& a, const T& b) {
    a.insert(a.end(), b);
    return a;
  }
  template <class T>
  std::vector<T>& operator+=(std::vector<T>& a, T&& b) {
    a.insert(a.end(), std::forward<T>(b));
    return a;
  }
  template <class T>
  std::vector<T> operator+(std::vector<T> a, const std::vector<T>& b) {
    a += b;
    return a;
  }
  template <class T>
  std::vector<T> operator+(std::vector<T> a, T& b) {
    a += b;
    return a;
  }
  template <class T>
  std::vector<T> operator+(std::vector<T> a, T&& b) {
    a += std::forward<T>(b);
    return a;
  }
  cm::scanner<cm::optimal_reader> sc(stdin);
  int main() {
    std::mt19937 rd(20050610);
    int n = sc.next_int();
    std::set<int> a;
    for (int i = 0; i < n; i++) a.insert(sc.next_int());
    std::set<int> cur_values;
    int cur_cnt = 0;
    if ((int)a.size() == n) {
      std::vector<int> rem[2];
      for (int x : a) rem[x % 2].push_back(x);
      if (rem[0].size() >= 3) {
        puts("YES");
        int sum = (rem[0][0] + rem[0][1] + rem[0][2]) / 2;
        printf("%d ", sum - rem[0][0]);
        cur_values.insert(sum - rem[0][0]);
        a.erase(rem[0][0]);
        printf("%d ", sum - rem[0][1]);
        cur_values.insert(sum - rem[0][1]);
        a.erase(rem[0][1]);
        printf("%d ", sum - rem[0][2]);
        cur_values.insert(sum - rem[0][2]);
        a.erase(rem[0][2]);
        cur_cnt = 3;
      } else if (rem[0].size() >= 1 && rem[1].size() >= 2) {
        puts("YES");
        int sum = (rem[0][0] + rem[1][0] + rem[1][1]) / 2;
        printf("%d ", sum - rem[0][0]);
        cur_values.insert(sum - rem[0][0]);
        a.erase(rem[0][0]);
        printf("%d ", sum - rem[1][0]);
        cur_values.insert(sum - rem[1][0]);
        a.erase(rem[1][0]);
        printf("%d ", sum - rem[1][1]);
        cur_values.insert(sum - rem[1][1]);
        a.erase(rem[1][1]);
        cur_cnt = 3;
      } else if (rem[1].size() >= 4) {
        std::vector<int> b = rem[1];
        std::vector<int> pa, pb;
        bool find_ans = false;
        while (static_cast<double>(clock()) / CLOCKS_PER_SEC <= 0.5) {
          std::shuffle(b.begin(), b.end(), rd);
          for (int l = 2; l * 2 <= (int)b.size(); l++) {
            std::unordered_map<int, int> psum;
            psum.reserve(b.size() * 4);
            int cur = std::accumulate(b.begin(), b.begin() + (l - 1), 0);
            for (int i = l; i <= (int)b.size(); i++) {
              cur += b[i - 1];
              if (psum.count(cur)) {
                int pre = psum[cur];
                pa = std::vector<int>(b.begin() + pre, b.begin() + pre + l);
                pb = std::vector<int>(b.begin() + (i - l), b.begin() + i);
                find_ans = true;
                goto done;
              }
              psum[cur] = i - l;
              cur -= b[i - l];
            }
          }
        }
      done:
        if (find_ans) {
          puts("YES");
          std::vector<int> p;
          for (size_t i = 0; i < pa.size(); i++) {
            p.push_back(pa[i]);
            p.push_back(pb[i]);
            a.erase(pa[i]);
            a.erase(pb[i]);
          }
          cur_cnt = (int)p.size();
          int cur = 0;
          printf("0 ");
          cur_values.insert(0);
          p.pop_back();
          for (int x : p) printf("%d ", cur = x - cur);
        } else {
          puts("NO");
          return 0;
        }
      } else {
        puts("NO");
        return 0;
      }
    } else {
      puts("YES");
      printf("0 ");
      cur_values.insert(0);
      cur_cnt = 1;
    }
    for (int x : a) {
      int by_pass = *cur_values.begin();
      printf("%d ", x - by_pass);
      cur_cnt++;
    }
    while (cur_cnt < n) {
      printf("0 ");
      cur_cnt++;
    }
    return 0;
  }
  