description: In the year 2420 humans have finally built a colony on Mars thanks to the work of Elon Tusk. There are 10^9+7 cities arranged in a circle in this colony and none of them are connected yet. Elon Tusk wants to connect some of those cities using only roads of the same size in order to lower the production cost of those roads. Because of that he gave a list on N cites where some cites can appear more than once and Q queries that you need to answer. For the query you need to determine if it is possible to connect all the cities from L_{i} to R_{i} on that list using only roads of length D_{i}. 
  
  Input
  
  The first line contains two integers N and Q (1 ≤ N, Q ≤ 2⋅10^5 ) — the length of the array of cities and the number of queries you need to answer. 
  
  The second lines contains N integers representing the array of cites. Next Q lines contain three integers L, R and D (1 ≤ L_{i}, R_{i} ≤ N, 0 ≤ D_{i} ≤ 10^9+6) — the range of cities that needs to be connected and the length of the road that you can use. 
  
  Output
  
  The output contains Q lines. If it is possible to connect all the cities from the i-th query can be connected with roads of length D_{i} the i-th line should contain the word "Yes", otherwise it should contain the word "No". 
  
  Examples
  
  Input
  
  
  9 8
  17 0 12 6 10 8 2 4 5
  2 3 12
  2 3 6
  2 4 6
  4 6 2
  2 8 2
  1 2 17
  1 8 2
  9 9 14
  
  
  Output
  
  
  Yes
  No
  Yes
  Yes
  Yes
  Yes
  No
  Yes
  
  
  Input
  
  
  4 1
  7 21 14 0
  1 4 1000000000
  
  
  Output
  
  
  Yes
  
  Note
  
  In the 5^{th} query of the first test case we can connect cities in this order 0-2-4-6-8-10-12 this way distance between any two connected cities is 2. In the second test case we can connect cities in this order 21-14-7-0 this way distance between any two connected cities is 10^9 module 10^9+7. 
solution: #include <bits/stdc++.h>
  namespace std {
  template <typename...>
  using void_t = void;
  }
  template <typename T, typename _ = void>
  struct is_container : std::false_type {};
  template <typename... Ts>
  struct is_container_helper {};
  template <typename T>
  struct is_container<
      T, typename std::conditional<
             false,
             is_container_helper<decltype(std::declval<T>().size()),
                                 decltype(std::declval<T>().begin()),
                                 decltype(std::declval<T>().end()),
                                 decltype(std::declval<T>().cbegin()),
                                 decltype(std::declval<T>().cend())>,
             void>::type> : public std::true_type {};
  class IO {
    static const int bufSize = 1 << 20;
    char inBuf[bufSize], outBuf[bufSize];
    char *ip1 = inBuf, *ip2 = inBuf;
    int goodReadBit = 1, op1 = -1, op2 = bufSize - 1;
    __inline__ __attribute__((always_inline)) int gc() {
      return ip1 == ip2 && (ip2 = (ip1 = inBuf) + fread(inBuf, 1, bufSize, stdin),
                            ip1 == ip2)
                 ? (goodReadBit = 0, EOF)
                 : *ip1++;
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) void __RI(T &x) {
      int ch = gc(), neg = 1;
      x = 0;
      for (; !(isdigit(ch) || ch == '-' || ch == EOF); ch = gc()) {
      }
      if (ch == EOF) return;
      if (ch == '-') neg = -1, ch = gc();
      for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - 48) * neg;
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) void __RC(T &x) {
      int ch;
      while (isspace(ch = gc())) {
      }
      if (ch == EOF) return;
      x = ch;
    }
    __inline__ __attribute__((always_inline)) void __RS(std::string &x) {
      char ch;
      x.clear();
      for (ch = gc(); isspace(ch); ch = gc()) {
      }
      if (ch == EOF) return;
      for (; !isspace(ch) && ch != EOF; ch = gc()) x.push_back(ch);
    }
  
   public:
    __inline__ __attribute__((always_inline)) IO &R(char &x) {
      return __RC(x), (*this);
    }
    __inline__ __attribute__((always_inline)) IO &R(unsigned char &x) {
      return __RC(x), (*this);
    }
    __inline__ __attribute__((always_inline)) IO &R(std::string &x) {
      return __RS(x), (*this);
    }
    template <typename T1, typename T2>
    __inline__ __attribute__((always_inline)) IO &R(std::pair<T1, T2> &x) {
      return R(x.first), R(x.second), (*this);
    }
    template <typename T, typename... Args>
    __inline__ __attribute__((always_inline)) IO &RA(T *a, int n) {
      for (int i = 0; i < n; ++i) R(a[i]);
      return (*this);
    }
    template <typename T, typename... Args>
    __inline__ __attribute__((always_inline)) IO &R(T &x, Args &...args) {
      return R(x), R(args...), (*this);
    }
    template <typename T, typename... Args>
    __inline__ __attribute__((always_inline)) IO &RA(T *a, int n, Args... args) {
      for (int i = 0; i < n; ++i) RA(a[i], args...);
      return (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline))
    typename std::enable_if<std::is_integral<T>::value, IO>::type &
    R(T &x) {
      return __RI(x), (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline))
    typename std::enable_if<is_container<T>::value, IO>::type &
    R(T &x) {
      for (auto &i : x) R(i);
      return (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) typename std::enable_if<
        std::is_void<std::void_t<decltype(std::declval<T>().read())>>::value,
        IO>::type &
    R(T &x) {
      return x.read(), (*this);
    }
  
   private:
    char space = ' ';
    __inline__ __attribute__((always_inline)) void pc(const char &x) {
      if (op1 == op2) flush();
      outBuf[++op1] = x;
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) void __WI(T x) {
      static char buf[sizeof(T) * 16 / 5];
      static int len = -1;
      if (x >= 0) {
        do {
          buf[++len] = x % 10 + 48, x /= 10;
        } while (x);
      } else {
        pc('-');
        do {
          buf[++len] = -(x % 10) + 48, x /= 10;
        } while (x);
      }
      while (len >= 0) {
        pc(buf[len]), --len;
      }
    }
  
   public:
    __inline__ __attribute__((always_inline)) void flush() {
      fwrite(outBuf, 1, op1 + 1, stdout), op1 = -1;
    }
    __inline__ __attribute__((always_inline)) IO &W(const char &x) {
      return pc(x), (*this);
    }
    __inline__ __attribute__((always_inline)) IO &W(const char *x) {
      while (*x != '\0') pc(*(x++));
      return (*this);
    }
    __inline__ __attribute__((always_inline)) IO &W(const std::string &x) {
      return W(x.c_str()), (*this);
    }
    template <typename T1, typename T2>
    __inline__ __attribute__((always_inline)) IO &W(const std::pair<T1, T2> &x) {
      WS(x.first);
      W(x.second);
      return (*this);
    }
    __inline__ __attribute__((always_inline)) IO &WL() {
      return W('\n'), (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) IO &WL(const T &x) {
      return W(x), W('\n'), (*this);
    }
    __inline__ __attribute__((always_inline)) IO &WS() {
      return W(space), (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) IO &WS(const T &x) {
      return W(x), W(space), (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) IO &WA(T *a, int n) {
      for (int i = 0; i < n; i++) WS(a[i]);
      WL();
      return (*this);
    }
    template <typename T, typename... Args>
    __inline__ __attribute__((always_inline)) IO &W(const T &x,
                                                    const Args &...args) {
      W(x), W(space), W(args...);
      return (*this);
    }
    template <typename T, typename... Args>
    __inline__ __attribute__((always_inline)) IO &WS(const T &x,
                                                     const Args &...args) {
      return W(x), W(space), W(args...), W(space), (*this);
    }
    template <typename... Args>
    __inline__ __attribute__((always_inline)) IO &WL(const Args &...args) {
      return W(args...), W('\n'), (*this);
    }
    template <typename T, typename... Args>
    __inline__ __attribute__((always_inline)) IO &WA(T *a, int n, Args... args) {
      for (int i = 0; i < n; i++) WA(a[i], args...);
      return (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline))
    typename std::enable_if<std::is_integral<T>::value, IO>::type &
    W(const T &x) {
      return __WI(x), (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline))
    typename std::enable_if<is_container<T>::value, IO>::type &
    W(const T &x) {
      for (auto &i : x) WS(i);
      WL();
      return (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) typename std::enable_if<
        std::is_void<std::void_t<decltype(std::declval<T>().write())>>::value,
        IO>::type &
    W(const T &x) {
      return x.write(), (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) IO &operator>>(T &x) {
      R(x);
      return (*this);
    }
    template <typename T>
    __inline__ __attribute__((always_inline)) IO &operator<<(const T &x) {
      W(x);
      return (*this);
    }
    int good() { return goodReadBit; }
    IO() {}
    ~IO() { flush(); }
  } io;
  const std::int32_t INF = 0x3f3f3f3f;
  const std::int64_t INFL = 0x3f3f3f3f3f3f3f3f;
  using namespace std;
  namespace Math {
  template <typename T, typename T2>
  T qpow(T a, T2 b, const int &MOD) {
    T ans = 1;
    for (; b; b >>= 1) {
      if (b & 1) ans = (a * ans) % MOD;
      a = (a * a) % MOD;
    }
    return ans;
  }
  template <typename T>
  T exgcd(T l, T r, T &x, T &y) {
    if (!r) {
      x = 1, y = 0;
      return l;
    } else {
      int d = exgcd(r, l % r, y, x);
      y -= l / r * x;
      return d;
    }
  }
  template <typename T>
  T inv(T a, const int &MOD) {
    return qpow(a, MOD - 2, MOD);
  }
  template <typename T>
  T exinv(T a, const int &MOD) {
    T x, y;
    exgcd(a, MOD, x, y);
    x %= MOD;
    return x + ((x >> (sizeof(T) * 8 - 1)) & MOD);
  }
  template <typename T, T MOD>
  struct ModInt {
    T x;
    ModInt(T x = 0) : x(x) {
      while (x < 0) x += MOD;
    }
    ModInt<T, MOD> operator+=(const ModInt<T, MOD> &y) {
      x += y.x - MOD;
      x += (x >> (sizeof(T) * 8 - 1)) & MOD;
      return (*this);
    }
    ModInt<T, MOD> operator-=(const ModInt<T, MOD> &y) {
      x = x - y.x;
      x += (x >> (sizeof(T) * 8 - 1)) & MOD;
      return (*this);
    }
    ModInt<T, MOD> operator*=(const ModInt<T, MOD> &y) {
      x = x * y.x % MOD;
      return (*this);
    }
    ModInt<T, MOD> operator/=(const ModInt<T, MOD> &y) {
      x = x * inv(y.x, MOD) % MOD;
      return (*this);
    }
    ModInt<T, MOD> pow(int64_t p) { return x = qpow(x, p, MOD), *this; }
    void write() const { io.W(x); }
    void read() {
      io.R(x);
      x %= MOD;
      if (x < 0) x += MOD;
    }
  };
  template <typename T, T MOD>
  ModInt<T, MOD> operator+(ModInt<T, MOD> a, const ModInt<T, MOD> &b) {
    a += b;
    return a;
  }
  template <typename T, T MOD>
  ModInt<T, MOD> operator-(ModInt<T, MOD> a, const ModInt<T, MOD> &b) {
    a -= b;
    return a;
  }
  template <typename T, T MOD>
  ModInt<T, MOD> operator*(ModInt<T, MOD> a, const ModInt<T, MOD> &b) {
    a *= b;
    return a;
  }
  template <typename T, T MOD>
  ModInt<T, MOD> operator/(ModInt<T, MOD> a, const ModInt<T, MOD> &b) {
    a /= b;
    return a;
  }
  template <typename T, T MOD>
  bool operator==(const ModInt<T, MOD> &a, const ModInt<T, MOD> &b) {
    return a.x == b.x;
  }
  }  // namespace Math
  using mint = Math::ModInt<int64_t, int(1e9 + 7)>;
  int main() {
    int n, q;
    io.R(n, q);
    vector<mint> a(n);
    io.R(a);
    a.insert(a.begin(), mint(0));
    vector<mint> preSum(n + 1), preSquareSum(n + 1);
    partial_sum(a.begin(), a.end(), preSum.begin());
    partial_sum(a.begin(), a.end(), preSquareSum.begin(),
                [](mint a, mint b) { return a + b * b; });
    mint inv2 = mint(1) / mint(2);
    mint inv6 = mint(1) / mint(6);
    while (q--) {
      int l, r, d;
      io.R(l, r, d);
      mint len = r - l + 1;
      mint x = ((preSum[r] - preSum[l - 1]) * mint(2) / len -
                (len - mint(1)) * mint(d)) *
               inv2;
      mint y = x * x * len + x * (len - mint(1)) * len * mint(d) +
               len * (mint(2) * len * len - mint(3) * len + mint(1)) * mint(d) *
                   mint(d) * inv6;
      mint z = (preSquareSum[r] - preSquareSum[l - 1]);
      io.WL(y == z ? "Yes" : "No");
    }
    return 0;
  }
  