#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long maxn = 25e4 + 10, inf = 4e18, mod = 1e9 + 7;
const long double pi = 3.14159265359, eps = 1e-9;
struct truck {
  long long s, f, c, r;
};
long long n, m, a[maxn], id[maxn];
truck t[maxn];
long long nw, tt, fix;
bool check(long long v) {
  nw = v;
  tt = t[fix].r;
  for (int j = t[fix].s; j < t[fix].f; j++) {
    if ((a[j + 1] - a[j]) * t[fix].c > v) return 0;
    nw -= (a[j + 1] - a[j]) * t[fix].c;
    if (nw < 0) nw = v - (a[j + 1] - a[j]) * t[fix].c, tt--;
  }
  return tt >= 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(unsigned(std::time(0)));
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> t[i].s >> t[i].f >> t[i].c >> t[i].r;
  }
  for (int i = 0; i < m; i++) id[i] = i;
  random_shuffle(id, id + m);
  long long l, r, mid, jj = 0;
  for (int i = 0; i < m; i++) {
    fix = id[i];
    if (check(jj)) continue;
    l = jj;
    r = inf;
    while (r - l > 1) {
      mid = (l + r) / 2;
      if (check(mid))
        r = mid;
      else
        l = mid;
    }
    jj = r;
  }
  cout << jj << endl;
  return 0;
}
