#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
std::istream& operator>>(std::istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& out, pair<T1, T2>& a) {
  out << a.first << " " << a.second;
  return out;
}
const long long N = 0;
long long a[405];
vector<pair<pair<long long, long long>, pair<long long, long long>>> v;
bool check(long long s, long long f, long long c, long long r, long long v) {
  long long cnt = 0;
  s--, f--;
  long long cur = v;
  for (long long i = s; i < f; ++i) {
    long long diff = a[i + 1] - a[i];
    if (diff * c > v) return 0;
    if (cur >= diff * c) {
      cur -= diff * c;
    } else {
      cnt++;
      cur = v - diff * c;
    }
  }
  return cnt <= r;
}
long long check(pair<pair<long long, long long>, pair<long long, long long>> p,
                long long v) {
  return check(p.first.first, p.first.second, p.second.first, p.second.second,
               v);
}
void solve() {
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  v.resize(m);
  for (long long i = 0; i < m; i++) {
    cin >> v[i];
  }
  shuffle((v).begin(), (v).end(), rng);
  long long cm = 0;
  for (long long i = 0; i < m; i++) {
    if (check(v[i], cm + 1)) continue;
    long long L = cm, U = 1e18 + 4;
    while (L <= U) {
      long long mid = (L + U) / 2;
      if (check(v[i], mid)) {
        U = mid - 1;
      } else {
        L = mid + 1;
        cm = max(cm, mid);
      }
    }
  }
  cout << cm + 1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long t = 1;
  while (t--) solve();
  return 0;
}
