#include <bits/stdc++.h>
using namespace std;
const int N = 405, M = 250005;
int n, m, p[N], a[M], b[M], c[M], d[M];
vector<int> id[N];
long long f[N][N][2], ans;
int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) p[i] = read();
  for (int i = 1; i <= m; ++i) {
    a[i] = read(), b[i] = read(), c[i] = read(), d[i] = read() + 1;
    d[i] = min(d[i], b[i] - a[i]);
    id[d[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) f[i][j][0] = p[j] - p[i];
  for (int k = 1; k < n; ++k) {
    for (int i = 0; i < id[k].size(); ++i)
      ans = max(ans, f[a[id[k][i]]][b[id[k][i]]][k + 1 & 1] * c[id[k][i]]);
    for (int i = 1; i <= n; ++i) {
      f[i][i][k & 1] = 0;
      int pos = i;
      for (int j = i + 1; j <= n; ++j) {
        while (f[i][pos][k + 1 & 1] < p[j] - p[pos]) ++pos;
        f[i][j][k & 1] = min(f[i][pos][k + 1 & 1], 0ll + p[j] - p[pos - 1]);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
