#include <bits/stdc++.h>
using namespace std;
struct truck {
  int s, f, c, r;
};
vector<int> a;
bool can(truck& t, long long& v) {
  long long curr, rf = 0, fu = v;
  for (int i = t.s; i < t.f; i++) {
    curr = 1LL * (a[i] - a[i - 1]) * t.c;
    rf += (curr > fu);
    fu = (fu >= curr ? fu : v) - curr;
    if (fu < 0 || rf > t.r) return false;
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  a.resize(n);
  for (int& i : a) scanf("%d", &i);
  vector<truck> b(m);
  for (truck& t : b) scanf("%d%d%d%d", &t.s, &t.f, &t.c, &t.r);
  sort(b.begin(), b.end(), [&](truck& i, truck& j) {
    return 1.0 * (a[i.f - 1] - a[i.s - 1]) * i.c * j.r >
           1.0 * (a[j.f - 1] - a[j.s - 1]) * j.c * i.r;
  });
  long long v = 0;
  for (truck& t : b)
    if (!can(t, v)) {
      long long st = v + 1, en = 1e18, mid;
      while (st <= en)
        can(t, mid = (st + en) >> 1) ? en = mid - 1 : st = mid + 1;
      v = st;
    }
  printf("%I64d\n", v);
}
