#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400;
const int INF = 0x3f3f3f3f;
const int MAXM = 250000;
int a[MAXN + 5], n, m;
int s[MAXM + 5], t[MAXM + 5], c[MAXM + 5];
vector<int> id[MAXN + 5];
inline void Init() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1, r; i <= m; ++i) {
    scanf("%d %d %d %d", &s[i], &t[i], &c[i], &r);
    ++r;
    r = min(r, t[i] - s[i]);
    id[r].push_back(i);
  }
}
int f[MAXN + 5][MAXN + 5][2], now;
inline void Getf() {
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) f[i][j][now] = a[j] - a[i];
  long long ans = -INF;
  for (auto i : id[1]) ans = max(ans, 1ll * f[s[i]][t[i]][now] * c[i]);
  for (int k = 2; k <= n; ++k) {
    now ^= 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = i, l = i; j <= n; ++j) {
        while (f[i][l][now ^ 1] < a[j] - a[l]) ++l;
        f[i][j][now] = min(f[i][l][now ^ 1], a[j] - a[l - 1]);
      }
    }
    for (auto i : id[k]) ans = max(ans, 1ll * f[s[i]][t[i]][now] * c[i]);
  }
  printf("%lld\n", ans);
}
signed main() {
  Init();
  Getf();
  return 0;
}
