#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 3e5 + 5;
struct truck {
  int s, f, r, c;
};
int a[500];
truck T[MAXN];
int n, m;
bool check(truck tr, long long V) {
  int s = tr.s, f = tr.f, r = tr.r;
  long long c = tr.c;
  long long cur = V;
  for (int i = s; i < f; i++) {
    if (V < (a[i + 1] - a[i]) * c) return 0;
    if (cur < (a[i + 1] - a[i]) * c) cur = V, r--;
    cur -= (a[i + 1] - a[i]) * c;
  }
  return r >= 0;
}
long long BS(truck tr) {
  long long lo = 0, hi = INFLL;
  while (lo < hi) {
    long long mi = lo + (hi - lo) / 2;
    if (check(tr, mi))
      hi = mi;
    else
      lo = mi + 1;
  }
  return lo;
}
long long BS() {
  random_shuffle(T, T + m);
  long long mx = 0;
  for (int i = 0; i < m; i++) {
    if (check(T[i], mx)) continue;
    mx = max(mx, BS(T[i]));
  }
  return mx;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &T[i].s, &T[i].f);
    T[i].s--, T[i].f--;
    scanf("%d %d", &T[i].c, &T[i].r);
  }
  printf("%lld\n", BS());
  return 0;
}
