#include <bits/stdc++.h>
using namespace std;
struct node {
  int s, f, c, r;
};
vector<node> vec[420];
pair<int, int> st[420];
int f[420][420];
int n, m, a[420], tops, mx[420][420];
long long ans;
int main() {
  scanf("%d %d", &n, &m);
  for (register int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (register int i = 1; i <= n; i++)
    for (register int j = i + 1; j <= n; j++) {
      mx[i][j] = max(mx[i][j - 1], a[j] - a[j - 1]);
    }
  for (register int i = 1; i <= m; i++) {
    int s, f, c, r;
    scanf("%d %d %d %d", &s, &f, &c, &r);
    vec[s].push_back((node){s, f, c, r});
  }
  for (register int s = 1; s <= n; s++) {
    tops = 0;
    for (register int i = s; i <= n; i++) f[i][0] = a[i] - a[s];
    for (register int k = 1; k <= n - s; k++) {
      int id = s;
      for (register int i = s + 1; i <= n; i++) {
        while (id < i - 1 && max(f[id][k - 1], a[i] - a[id]) >
                                 max(f[id + 1][k - 1], a[i] - a[id + 1]))
          ++id;
        f[i][k] = max(f[id][k - 1], a[i] - a[id]);
      }
    }
    for (register int i = 0; i < (int)vec[s].size(); i++) {
      node cur = vec[s][i];
      ans = max(ans, (long long)cur.c * f[cur.f][min(cur.r, n - s)]);
    }
  }
  cout << ans << endl;
}
