#include <bits/stdc++.h>
using namespace std;
struct aaa {
  long long t, c, r;
} b[300010];
long long ans, n, m, i, j, s, t, la, x, a[300010], f[402][402];
vector<long long> zh[402];
int main() {
  scanf("%lld%lld", &n, &m);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld%lld%lld", &s, &b[i].t, &b[i].c, &b[i].r);
    zh[s].push_back(i);
  }
  for (s = 1; s <= n; s++) {
    memset(f, 44, sizeof(f));
    for (j = 0; j <= n; j++) f[s][j] = 0;
    for (i = s + 1; i <= n; i++) f[i][0] = a[i] - a[s];
    for (j = 1; j <= n; j++) {
      la = s;
      for (i = s + 1; i <= n; i++) {
        while (la < i - 1 && f[la + 1][j - 1] <= a[i] - a[la + 1]) la++;
        f[i][j] = a[i] - a[la];
        if (la < i - 1) f[i][j] = min(f[i][j], f[la + 1][j - 1]);
        f[i][j] = min(f[i][j], f[i][j - 1]);
      }
    }
    for (i = 0; i < zh[s].size(); i++) {
      x = zh[s][i];
      t = b[x].t;
      la = f[t][b[x].r] * b[x].c;
      ans = max(ans, la);
    }
  }
  printf("%lld", ans);
}
