#include <bits/stdc++.h>
using namespace std;
const int maxn = 405;
int n, m, a[maxn], nxt[maxn];
struct node {
  int s, t, oil;
};
int f[maxn][maxn][2];
vector<node> hh[maxn];
void read() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    int s, t, oil, tms;
    scanf("%d%d%d%d", &s, &t, &oil, &tms);
    tms = min(tms, t - s - 1) + 1;
    hh[tms].push_back((node){s, t, oil});
  }
}
void work() {
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) f[i][j][1] = a[j] - a[i];
  for (int k = 1; k <= n - 1; k++) {
    for (int i = 0; i < hh[k].size(); i++)
      ans = max(ans, 1ll * f[hh[k][i].s][hh[k][i].t][k & 1] * hh[k][i].oil);
    for (int i = 1; i <= n; i++) {
      f[i][i][(k + 1) & 1] = 0;
      int pts = i;
      for (int j = i + 1; j <= n; j++) {
        while (f[i][pts][k & 1] < a[j] - a[pts]) pts++;
        f[i][j][(k + 1) & 1] = min(f[i][pts][k & 1], a[j] - a[pts - 1]);
      }
    }
  }
  printf("%lld\n", ans);
}
int main() {
  read();
  work();
  return 0;
}
