#include <bits/stdc++.h>
int ss[250000], ff[250000], cc[250000], rr[250000], ii[250000];
int compare(const void *a, const void *b) {
  int i = *(int *)a;
  int j = *(int *)b;
  return rr[i] - rr[j];
}
int main() {
  static int aa[400];
  typedef int ian[400];
  static ian dp_[400], dq_[400], *dp = dp_, *dq = dq_, *tmp;
  int n, m, h, h_, i, r, s, f;
  long long v;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", &aa[i]);
  for (h = 0; h < m; h++) {
    scanf("%d%d%d%d", &ss[h], &ff[h], &cc[h], &rr[h]);
    ss[h]--;
    ff[h]--;
    ii[h] = h;
  }
  qsort(ii, m, sizeof *ii, compare);
  for (s = 0; s < n; s++)
    for (f = s + 1; f < n; f++) dp[s][f] = aa[f] - aa[s];
  v = 0;
  for (r = 0, h_ = 0; r <= n; r++) {
    while (h_ < m && rr[h = ii[h_]] == r) {
      long long x;
      if (v < (x = (long long)dp[ss[h]][ff[h]] * cc[h])) v = x;
      h_++;
    }
    for (s = 0; s < n; s++) {
      i = s;
      for (f = s + 1; f < n; f++) {
        while (i < f && dp[s][i] < aa[f] - aa[i]) i++;
        dq[s][f] = aa[f] - aa[i - 1];
        if (dq[s][f] > dp[s][i]) dq[s][f] = dp[s][i];
      }
    }
    tmp = dp;
    dp = dq;
    dq = tmp;
  }
  printf("%lld\n", v);
  return 0;
}
