#include <bits/stdc++.h>
using namespace std;
const int M = 405;
const int N = 250005;
int read() {
  int x = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * flag;
}
int n, m, t[M], a[N], b[N], c[N], d[N], dp[2][M][M];
vector<int> v[M];
long long ans;
signed main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) t[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]);
    v[d[i]].push_back(i);
  }
  memset(dp, 0x3f, sizeof dp);
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) dp[1][i][j] = t[j] - t[i];
  for (int k = 1; k < n; k++) {
    for (int i = 0; i < v[k].size(); i++) {
      int x = v[k][i];
      ans = max(ans, 1ll * dp[k & 1][a[x]][b[x]] * c[x]);
    }
    for (int i = 1; i <= n; i++) dp[(k + 1) & 1][i][i] = 0;
    for (int i = 1; i <= n; i++) {
      int l = i;
      for (int j = i + 1; j <= n; j++) {
        while (dp[k & 1][i][l] < t[j] - t[l]) l++;
        dp[(k + 1) & 1][i][j] = min(dp[k & 1][i][l], t[j] - t[l - 1]);
      }
    }
  }
  printf("%lld\n", ans);
}
