#include <bits/stdc++.h>
using namespace std;
const int maxn = 401;
int n, m, a[maxn], cost[maxn][maxn];
long long dp[2][maxn][maxn];
struct Q {
  int l, r, c;
};
vector<Q> assign[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  memset(dp[0], 63, sizeof dp[0]);
  int last;
  cin >> n >> m >> last;
  n--;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= last;
    last += a[i];
    dp[0][i][i] = 0;
  }
  while (m--) {
    int l, r, c, k;
    cin >> l >> r >> c >> k, l--, r--;
    assign[k].push_back({l, r, c});
  }
  long long ans = 0;
  for (int k = 0; k <= n + 1; k++) {
    memset(cost, 0, sizeof cost);
    for (auto [l, r, c] : assign[k]) cost[l][r] = max(cost[l][r], c);
    for (int l = 0; l < n; l++) {
      int ptr = l;
      long long cur = 0;
      for (int r = l + 1; r <= n; r++) {
        cur += a[r - 1];
        while (ptr < r &&
               max(cur, dp[0][l][ptr]) > max(cur - a[ptr], dp[0][l][ptr + 1]))
          cur -= a[ptr++];
        dp[1][l][r] = max(cur, dp[0][l][ptr]);
        ans = max(ans, cost[l][r] * dp[1][l][r]);
      }
    }
    memcpy(dp[0], dp[1], sizeof dp[0]);
  }
  cout << ans << '\n';
}
