#include <bits/stdc++.h>
using namespace std;
const int maxn = 405;
const int maxm = 250005;
int n, m, a[maxn];
long long dp[2][maxn][maxn];
struct Car {
  int r, s, f, c;
  void read() { scanf("%d%d%d%d", &s, &f, &c, &r); }
  bool operator<(const Car& x) const {
    if (r != x.r) return r < x.r;
    if (s != x.s) return s < x.s;
    if (f != x.f) return f < x.f;
    return c < x.c;
  }
  bool operator==(const Car& x) const {
    return r == x.r && s == x.s && f == x.f;
  }
} car[maxm];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 1; i <= m; i++) {
    car[i].read();
    car[i].r++;
  }
  sort(car + 1, car + 1 + m);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      dp[1][i][j] = a[j] - a[i];
    }
  }
  int pl = 1;
  long long ans = 0;
  for (int r = 1; r <= n + 1; r++) {
    for (int i = 1; i <= n; i++) {
      int k = i;
      for (int j = i + 1; j <= n; j++) {
        Car cur = (Car){r, i, j, 0};
        for (; pl <= m && (car[pl] < cur || car[pl] == cur); pl++) {
          if (car[pl] < cur) continue;
          ans = max(ans, dp[r & 1][i][j] * car[pl].c);
        }
        for (; k < j && dp[r & 1][i][k] <= a[j] - a[k]; k++)
          ;
        k--;
        if (a[j] - a[k] <= dp[r & 1][i][k + 1]) {
          dp[~r & 1][i][j] = a[j] - a[k];
        } else {
          k++;
          dp[~r & 1][i][j] = dp[r & 1][i][k];
        }
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
