#include <bits/stdc++.h>
using namespace std;
long long n, m, d[410], ans;
long long s[250000], e[250000], c[250000], re[250000];
long long id[250000];
bool check(long long id, long long V) {
  long long start = s[id], end = e[id], cost = c[id], now = V, i, cnt = 0;
  for (i = start + 1; i <= end; i++) {
    if (V < cost * (d[i] - d[i - 1])) return 0;
    if (now < cost * (d[i] - d[i - 1])) {
      now = V;
      cnt++;
    }
    now -= cost * (d[i] - d[i - 1]);
  }
  return cnt <= re[id];
}
int main() {
  long long i, l, r, mid;
  srand(time(0));
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &d[i]);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d%d", &s[i], &e[i], &c[i], &re[i]);
    id[i] = i;
  }
  random_shuffle(id, id + m);
  for (i = 0; i < m; i++)
    if (!check(id[i], ans)) {
      l = ans;
      r = 4557430888798830399LL;
      while (l + 1 < r) {
        mid = (l + r) >> 1LL;
        if (check(id[i], mid))
          r = mid;
        else
          l = mid;
      }
      ans = max(ans, r);
    }
  printf("%lld", ans);
}
