#include <bits/stdc++.h>
using namespace std;
const int M = 2.5E5 + 5;
int n, m;
int a[401], b[401], s[M], f[M], c[M], r[M], r1[M], i, in, dis;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long val;
bool check() {
  dis = 0;
  r1[in] = r[in];
  for (i = s[in]; i < f[in]; i++) {
    if (1ll * dis * c[in] + 1ll * b[i] * c[in] > val) {
      r1[in]--;
      if (r1[in] < 0 || !dis) return 0;
      dis = 0;
      i--;
    } else
      dis += b[i];
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) b[i] = a[i + 1] - a[i];
  long long MAX = 0;
  for (i = 0; i < m; i++) {
    cin >> s[i] >> f[i] >> c[i] >> r[i];
  }
  vector<int> v(m);
  for (i = 0; i < m; i++) v[i] = i;
  shuffle(v.begin(), v.end(), rng);
  long long l, r1;
  for (int i = 0; i < m; i++) {
    in = v[i];
    val = MAX;
    if (check()) continue;
    l = MAX + 1;
    MAX = 1e18;
    while (l != MAX) {
      val = (l + MAX) / 2;
      if (check())
        MAX = val;
      else
        l = val + 1;
    }
  }
  cout << MAX;
}
