#include <bits/stdc++.h>
using namespace std;
const int maxn = 405;
const int inf = 0x3f3f3f3f;
int n, m;
int a[maxn];
int f[maxn][maxn][maxn];
template <typename T>
inline void minimize(T &target, const T &value) {
  if (target > value) {
    target = value;
  }
}
void divide(int a[], int f[], int g[], int l, int r, int pl, int pr) {
  if (l > r) {
    return;
  }
  int m = (l + r) / 2;
  int ptr = l;
  for (int i = pl; i < min(m, pr + 1); ++i) {
    int tmp = max(f[i], a[m] - a[i]);
    if (tmp < g[m]) {
      g[m] = tmp;
      ptr = i;
    }
  }
  divide(a, f, g, l, m - 1, pl, ptr);
  divide(a, f, g, m + 1, r, ptr, pr);
}
void compute(int a[], int n, int f[maxn][maxn]) {
  f[0][0] = 0;
  for (int i = 1; i < n; ++i) {
    divide(a, f[i - 1], f[i], 0, n - 1, 0, n - 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  memset(f, inf, sizeof(f));
  compute(a, n, f[0]);
  for (int i = 0; i < n; ++i) {
    compute(a + i, n - i, f[i]);
  }
  long long ans = 0;
  while (m--) {
    int s, f, c, r;
    scanf("%d%d%d%d", &s, &f, &c, &r), s--, f--;
    r++;
    r = min(r, f - s);
    r = max(r, 1);
    ans = max(ans, (long long)c * ::f[s][r][f - s]);
  }
  printf("%lld\n", ans);
  return 0;
}
